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

Yohan Boniface's avatar
Yohan Boniface committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
from django.db import models


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


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

24
    slug = models.SlugField(max_length=100)
Yohan Boniface's avatar
Yohan Boniface committed
25 26 27 28
    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
29
    gender = models.SmallIntegerField(choices=GENDER, default=N_A)
Yohan Boniface's avatar
Yohan Boniface committed
30 31 32 33
    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)

34 35 36
    class Meta:
        abstract = True

Yohan Boniface's avatar
Yohan Boniface committed
37 38

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)
Yohan Boniface's avatar
Yohan Boniface committed
61
    floor = models.SmallIntegerField(blank=True, null=True)
Yohan Boniface's avatar
Yohan Boniface committed
62 63 64 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
    office_number = models.CharField(max_length=255, blank=True, null=True)
    kind = models.CharField(max_length=255, blank=True, null=True)
    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)
94 95

    representative = models.ForeignKey("Representative")