models.py 1.46 KB
Newer Older
Aymeric Barantal's avatar
Aymeric Barantal committed
1
2
3
4
5
6
7
8
9
from django.db import models


class Contact(models.Model):
    """Contact model. Person to be call by users"""
    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
31

class Argumentary(models.Model):
    id = models.AutoField(primary_key=True)
Aymeric Barantal's avatar
Aymeric Barantal committed
32
    campaign = models.ForeignKey(Campaign)
Aymeric Barantal's avatar
Aymeric Barantal committed
33
    lang = models.CharField(max_length=255)
Aymeric Barantal's avatar
Aymeric Barantal committed
34
    text = models.TextField(null=True)
Aymeric Barantal's avatar
Aymeric Barantal committed
35
36
37
38
39


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
40
41
    campaign = models.ForeignKey(Campaign)
    contact = models.ForeignKey(Contact)
Aymeric Barantal's avatar
Aymeric Barantal committed
42
    weight = models.IntegerField(default=0)
Aymeric Barantal's avatar
Aymeric Barantal committed
43
44
45

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