models.py 1.05 KB
Newer Older
1
2
3
4
5
6
from datetime import datetime
from django.forms import fields
from django.core.urlresolvers import reverse

from django.db import models

7
from ckeditor.fields import RichTextField
8
9
10
11
12


class Emission(models.Model):
    title = models.CharField(max_length=50)
    slug = models.SlugField()
13
    description = RichTextField(null=True)
14

15
    first_diffusion = models.DateTimeField(null=True)
16
17
18
19
20
21
22
23
24
25
    # other_diffusions = 

    def __unicode__(self):
        return self.title


class Episode(models.Model):
    emission = models.ForeignKey('Emission', verbose_name=u'Emission')
    title = models.CharField(max_length=50)
    slug = models.SlugField()
26
    description = RichTextField(null=True)
27
28
29
30
31
32
33
34
35
36
37
38
39

    def __unicode__(self):
        return self.title

    def get_absolute_url(self):
        return reverse('episode-view',
                        kwargs={'emission_id': str(self.emission.id),
                                'pk':  str(self.id)})


class Diffusion(models.Model):
    episode = models.ForeignKey('Episode', verbose_name=u'Episode')
    datetime = models.DateTimeField()