models.py 988 Bytes
Newer Older
1
2
3
from django.db import models
from django.utils.encoding import smart_unicode

4
5
from autoslug import AutoSlugField

6
7
8
9
10
11
from representatives_votes.models import Dossier, Proposal
from representatives_positions.models import Position


class Theme(models.Model):
    name = models.CharField(max_length=255, unique=True)
12
    slug = AutoSlugField(populate_from='name')
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
    description = models.TextField()

    dossiers = models.ManyToManyField(Dossier, related_name='themes')
    proposals = models.ManyToManyField(Proposal, related_name='themes')
    positions = models.ManyToManyField(Position, related_name='themes')

    def __unicode__(self):
        return smart_unicode(self.name)


class ThemeLink(models.Model):
    title = models.CharField(max_length=511)
    datetime = models.DateField()
    link = models.URLField(max_length=500)
    theme = models.ForeignKey(Theme, related_name='links')

    def __unicode__(self):
        return smart_unicode('%s (%s)' % (self.title, self.link))