models.py 3.14 KB
Newer Older
1 2
# -*- coding:utf-8 -*-

Yohan Boniface's avatar
Yohan Boniface committed
3 4 5 6 7 8 9
from django.db import models


class Country(models.Model):
    name = models.CharField(max_length=255)
    code = models.CharField(max_length=2)

Bram's avatar
Bram committed
10 11 12
    def __unicode__(self):
        return "%s - %s" % (self.name, self.code)

Yohan Boniface's avatar
Yohan Boniface committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26

class Representative(models.Model):
    """
    FIXME
    """
    N_A = 0
    F = 1
    M = 2
    GENDER = (
        (N_A, "N/A"),
        (F, "F"),
        (M, "M"),
    )

27
    slug = models.SlugField(max_length=100)
Yohan Boniface's avatar
Yohan Boniface committed
28 29 30 31
    remote_id = models.CharField(max_length=255, blank=True, null=True)
    first_name = models.CharField(max_length=255, blank=True, null=True)
    last_name = models.CharField(max_length=255, blank=True, null=True)
    full_name = models.CharField(max_length=255)
Yohan Boniface's avatar
Yohan Boniface committed
32
    gender = models.SmallIntegerField(choices=GENDER, default=N_A)
Yohan Boniface's avatar
Yohan Boniface committed
33 34 35 36 37 38
    birth_place = models.CharField(max_length=255, blank=True, null=True)
    birth_date = models.DateField(blank=True, null=True)
    cv = models.TextField(blank=True, null=True)


class Contact(models.Model):
39
    representative = models.ForeignKey(Representative)
Yohan Boniface's avatar
Yohan Boniface committed
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

    class Meta:
        abstract = True


class Email(Contact):
    email = models.EmailField()
    kind = models.CharField(max_length=255, blank=True, null=True)


class WebSite(Contact):
    url = models.URLField()
    kind = models.CharField(max_length=255, blank=True, null=True)


class Address(Contact):
    country = models.ForeignKey(Country)
    city = models.CharField(max_length=255, blank=True, null=True)
    street = models.CharField(max_length=255, blank=True, null=True)
    number = models.CharField(max_length=255, blank=True, null=True)
    postcode = models.CharField(max_length=255, blank=True, null=True)
Bram's avatar
Bram committed
61
    floor = models.CharField(max_length=255, blank=True, null=True)
Yohan Boniface's avatar
Yohan Boniface committed
62 63
    office_number = models.CharField(max_length=255, blank=True, null=True)
    kind = models.CharField(max_length=255, blank=True, null=True)
Bram's avatar
Bram committed
64
    name = models.CharField(max_length=255, blank=True, null=True)
Yohan Boniface's avatar
Yohan Boniface committed
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
    location = models.CharField(max_length=255, blank=True, null=True)  # TODO Find standard for storage in charfield


class Phone(Contact):
    number = models.CharField(max_length=255)
    kind = models.CharField(max_length=255, blank=True, null=True)
    address = models.ForeignKey(Address)


class Mandate(models.Model):
    name = models.CharField(max_length=255)
    kind = models.CharField(max_length=255, blank=True, null=True)
    short_id = models.CharField(max_length=25, blank=True, null=True)
    url = models.URLField()
    constituency = models.CharField(
        max_length=255,
        blank=True,
        null=True,
        help_text="Authority for which the mandate is realized. Eg.: a eurodeputies has a mandate at the European Parliament for a country"
    )
    role = models.CharField(
        max_length=25,
        blank=True,
        null=True,
        help_text="Eg.: president of a political group at the European Parliament"
    )
    begin_date = models.DateField(blank=True, null=True)
    end_date = models.DateField(blank=True, null=True)
    # Sometimes begin_date and end_date are not available
    active = models.NullBooleanField(default=False)
95

96
    representative = models.ForeignKey(Representative)