Mercurial > public > sg101
comparison gpp/podcast/models.py @ 224:76ad86454ce9
For #51, adding podcasts to Haystack search.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 08 Jun 2010 03:09:48 +0000 |
parents | 1ed461fd2030 |
children | 405468b8e3b9 |
comparison
equal
deleted
inserted
replaced
223:cd4124b19196 | 224:76ad86454ce9 |
---|---|
1 """Models for the podcast application.""" | 1 """Models for the podcast application.""" |
2 | 2 |
3 from django.db import models | 3 from django.db import models |
4 | 4 |
5 EXPLICIT_CHOICES = ( | 5 EXPLICIT_CHOICES = ( |
6 ('yes', 'Yes'), | 6 ('yes', 'Yes'), |
7 ('no', 'No'), | 7 ('no', 'No'), |
8 ('clean', 'Clean'), | 8 ('clean', 'Clean'), |
9 ) | 9 ) |
10 | 10 |
11 | 11 |
12 class Channel(models.Model): | 12 class Channel(models.Model): |
13 """Model to represent the Channel properties""" | 13 """Model to represent the Channel properties""" |
14 | 14 |
15 title = models.CharField(max_length=255) | 15 title = models.CharField(max_length=255) |
16 link = models.URLField(verify_exists=False) | 16 link = models.URLField(verify_exists=False) |
17 language = models.CharField(max_length=16) | 17 language = models.CharField(max_length=16) |
18 copyright = models.CharField(max_length=255) | 18 copyright = models.CharField(max_length=255) |
19 subtitle = models.CharField(max_length=255) | 19 subtitle = models.CharField(max_length=255) |
20 author = models.CharField(max_length=64) | 20 author = models.CharField(max_length=64) |
21 description = models.CharField(max_length=255) | 21 description = models.CharField(max_length=255) |
22 owner_name = models.CharField(max_length=64) | 22 owner_name = models.CharField(max_length=64) |
23 owner_email = models.EmailField() | 23 owner_email = models.EmailField() |
24 image = models.ImageField(upload_to='podcast') | 24 image = models.ImageField(upload_to='podcast') |
25 category = models.CharField(max_length=64) | 25 category = models.CharField(max_length=64) |
26 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) | 26 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) |
27 keywords = models.CharField(max_length=255) | 27 keywords = models.CharField(max_length=255) |
28 | 28 |
29 def __unicode__(self): | 29 def __unicode__(self): |
30 return self.title | 30 return self.title |
31 | 31 |
32 | 32 |
33 class Item(models.Model): | 33 class Item(models.Model): |
34 """Model to represent a channel item""" | 34 """Model to represent a channel item""" |
35 channel = models.ForeignKey(Channel) | 35 channel = models.ForeignKey(Channel) |
36 title = models.CharField(max_length=255) | 36 title = models.CharField(max_length=255) |
37 author = models.CharField(max_length=255) | 37 author = models.CharField(max_length=255) |
38 subtitle = models.CharField(max_length=255) | 38 subtitle = models.CharField(max_length=255) |
39 summary = models.TextField() | 39 summary = models.TextField() |
40 enclosure_url = models.URLField(verify_exists=False) | 40 enclosure_url = models.URLField(verify_exists=False) |
41 alt_enclosure_url = models.URLField(verify_exists=False, blank=True) | 41 alt_enclosure_url = models.URLField(verify_exists=False, blank=True) |
42 enclosure_length = models.IntegerField() | 42 enclosure_length = models.IntegerField() |
43 enclosure_type = models.CharField(max_length=32) | 43 enclosure_type = models.CharField(max_length=32) |
44 guid = models.CharField(max_length=255) | 44 guid = models.CharField(max_length=255) |
45 pubdate = models.DateTimeField() | 45 pubdate = models.DateTimeField() |
46 duration = models.CharField(max_length=16) | 46 duration = models.CharField(max_length=16) |
47 keywords = models.CharField(max_length=255) | 47 keywords = models.CharField(max_length=255) |
48 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) | 48 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) |
49 | 49 |
50 @models.permalink | 50 @models.permalink |
51 def get_absolute_url(self): | 51 def get_absolute_url(self): |
52 return ('podcast.views.detail', [str(self.id)]) | 52 return ('podcast.views.detail', [str(self.id)]) |
53 | 53 |
54 def __unicode__(self): | 54 def __unicode__(self): |
55 return self.title | 55 return self.title |
56 | 56 |
57 class Meta: | 57 class Meta: |
58 ordering = ('-pubdate', ) | 58 ordering = ('-pubdate', ) |
59 | 59 |
60 def search_title(self): | |
61 return "%s: %s" % (self.title, self.subtitle) | |
62 | |
63 def search_summary(self): | |
64 return u"\n".join((self.subtitle, self.summary, self.keywords)) |