gremmie@1
|
1 """Models for the podcast application."""
|
gremmie@1
|
2
|
gremmie@1
|
3 from django.db import models
|
gremmie@1
|
4
|
gremmie@1
|
5 EXPLICIT_CHOICES = (
|
bgneal@224
|
6 ('yes', 'Yes'),
|
bgneal@224
|
7 ('no', 'No'),
|
bgneal@224
|
8 ('clean', 'Clean'),
|
bgneal@224
|
9 )
|
gremmie@1
|
10
|
gremmie@1
|
11
|
gremmie@1
|
12 class Channel(models.Model):
|
bgneal@224
|
13 """Model to represent the Channel properties"""
|
gremmie@1
|
14
|
bgneal@224
|
15 title = models.CharField(max_length=255)
|
bgneal@224
|
16 link = models.URLField(verify_exists=False)
|
bgneal@224
|
17 language = models.CharField(max_length=16)
|
bgneal@224
|
18 copyright = models.CharField(max_length=255)
|
bgneal@224
|
19 subtitle = models.CharField(max_length=255)
|
bgneal@224
|
20 author = models.CharField(max_length=64)
|
bgneal@224
|
21 description = models.CharField(max_length=255)
|
bgneal@224
|
22 owner_name = models.CharField(max_length=64)
|
bgneal@224
|
23 owner_email = models.EmailField()
|
bgneal@224
|
24 image = models.ImageField(upload_to='podcast')
|
bgneal@224
|
25 category = models.CharField(max_length=64)
|
bgneal@224
|
26 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES)
|
bgneal@224
|
27 keywords = models.CharField(max_length=255)
|
gremmie@1
|
28
|
bgneal@224
|
29 def __unicode__(self):
|
bgneal@224
|
30 return self.title
|
gremmie@1
|
31
|
gremmie@1
|
32
|
gremmie@1
|
33 class Item(models.Model):
|
bgneal@224
|
34 """Model to represent a channel item"""
|
bgneal@224
|
35 channel = models.ForeignKey(Channel)
|
bgneal@224
|
36 title = models.CharField(max_length=255)
|
bgneal@224
|
37 author = models.CharField(max_length=255)
|
bgneal@224
|
38 subtitle = models.CharField(max_length=255)
|
bgneal@224
|
39 summary = models.TextField()
|
bgneal@224
|
40 enclosure_url = models.URLField(verify_exists=False)
|
bgneal@224
|
41 alt_enclosure_url = models.URLField(verify_exists=False, blank=True)
|
bgneal@224
|
42 enclosure_length = models.IntegerField()
|
bgneal@224
|
43 enclosure_type = models.CharField(max_length=32)
|
bgneal@224
|
44 guid = models.CharField(max_length=255)
|
bgneal@224
|
45 pubdate = models.DateTimeField()
|
bgneal@224
|
46 duration = models.CharField(max_length=16)
|
bgneal@224
|
47 keywords = models.CharField(max_length=255)
|
bgneal@224
|
48 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES)
|
gremmie@1
|
49
|
bgneal@224
|
50 @models.permalink
|
bgneal@224
|
51 def get_absolute_url(self):
|
bgneal@224
|
52 return ('podcast.views.detail', [str(self.id)])
|
gremmie@1
|
53
|
bgneal@224
|
54 def __unicode__(self):
|
bgneal@224
|
55 return self.title
|
gremmie@1
|
56
|
bgneal@224
|
57 class Meta:
|
bgneal@224
|
58 ordering = ('-pubdate', )
|
gremmie@1
|
59
|
bgneal@224
|
60 def search_title(self):
|
bgneal@224
|
61 return "%s: %s" % (self.title, self.subtitle)
|
bgneal@224
|
62
|
bgneal@224
|
63 def search_summary(self):
|
bgneal@224
|
64 return u"\n".join((self.subtitle, self.summary, self.keywords))
|