models.py 933 Bytes
Newer Older
okhin's avatar
okhin committed
1 2 3
from django.db import models
from django.utils.translation import ugettext_lazy as _

okhin's avatar
okhin committed
4 5
from picampaign.campaign.models import Campaign

okhin's avatar
okhin committed
6 7 8 9 10 11 12 13
class Importer(models.Model):
    """Importer model. Used to populate campaign with contacts"""
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=64)
    kind = models.CharField(max_length=4, choices=[('FILE', _("File"))])
    data_format = models.CharField(max_length=4, choices=[('JSON', 'json'), ('CSV', 'csv')])
    file = models.FileField(upload_to='imports/', blank=True, null=True)
    url = models.URLField(blank=True, null=True)
okhin's avatar
okhin committed
14
    campaign = models.ForeignKey(Campaign, on_delete=models.SET_NULL, null=True)
okhin's avatar
okhin committed
15 16 17 18 19

    def __str__(self):
        return _(u'%{name}: %{format} %{type} importer' % {'format': self.data_format,
                                                'type': self.kind,
                                                'name': self.name})