models.py 1.62 KB
Newer Older
Aymeric Barantal's avatar
Aymeric Barantal committed
1 2 3 4
from django.db import models


class Contact(models.Model):
5
    """Contact model. Person to be called by users"""
Aymeric Barantal's avatar
Aymeric Barantal committed
6 7 8 9
    id = models.AutoField(primary_key=True)
    first_name = models.CharField(max_length=64)
    last_name = models.CharField(max_length=64)
    phone = models.CharField(max_length=32)
10 11 12 13 14
    twitter = models.CharField(max_length=64, blank=True)
    mail = models.CharField(max_length=255, blank=True)

    def __unicode__(self):
        return '%s %s' % (self.first_name, self.last_name)
Aymeric Barantal's avatar
Aymeric Barantal committed
15 16 17 18 19 20


class Campaign(models.Model):
    """Campaign model, describe what have to be achieved"""
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=255)
21
    description = models.CharField(max_length=512, blank=True)
22 23
    start_date = models.DateField()
    end_date = models.DateField()
Aymeric Barantal's avatar
Aymeric Barantal committed
24 25
    default_lang = models.CharField(max_length=5)

26 27 28
    def __unicode__(self):
        return self.title

Aymeric Barantal's avatar
Aymeric Barantal committed
29 30

class Argumentary(models.Model):
31
    """Argumentary in a given language for a campaign"""
Aymeric Barantal's avatar
Aymeric Barantal committed
32
    id = models.AutoField(primary_key=True)
Aymeric Barantal's avatar
Aymeric Barantal committed
33
    campaign = models.ForeignKey(Campaign)
Aymeric Barantal's avatar
Aymeric Barantal committed
34
    lang = models.CharField(max_length=255)
Aymeric Barantal's avatar
Aymeric Barantal committed
35
    text = models.TextField(null=True)
Aymeric Barantal's avatar
Aymeric Barantal committed
36

37 38 39
    def __unicode__(self):
        return 'Argumentary in %s for %s' % (self.lang, self.campaign.title)

Aymeric Barantal's avatar
Aymeric Barantal committed
40 41 42 43

class CampaignContact(models.Model):
    """List contact related to a campaign with a given weight"""
    id = models.AutoField(primary_key=True)
Aymeric Barantal's avatar
Aymeric Barantal committed
44 45
    campaign = models.ForeignKey(Campaign)
    contact = models.ForeignKey(Contact)
Aymeric Barantal's avatar
Aymeric Barantal committed
46
    weight = models.IntegerField(default=0)
Aymeric Barantal's avatar
Aymeric Barantal committed
47 48 49

    def __unicode__(self):
        return 'Contact %s on %s' % (self.contact, self.campaign.title)