Mercurial > public > sg101
comparison gpp/podcast/models.py @ 277:d424b8bae71d
Fixing #128 and #129. Add elsewhere weblinks to search content. Add support for haystack's get_update_field() method.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 02 Oct 2010 23:24:39 +0000 |
parents | 405468b8e3b9 |
children | 77d878acea5e |
comparison
equal
deleted
inserted
replaced
276:8a46843c258f | 277:d424b8bae71d |
---|---|
1 """Models for the podcast application.""" | 1 """ |
2 Models for the podcast application. | |
3 | |
4 """ | |
5 import datetime | |
2 | 6 |
3 from django.db import models | 7 from django.db import models |
8 | |
4 | 9 |
5 EXPLICIT_CHOICES = ( | 10 EXPLICIT_CHOICES = ( |
6 ('yes', 'Yes'), | 11 ('yes', 'Yes'), |
7 ('no', 'No'), | 12 ('no', 'No'), |
8 ('clean', 'Clean'), | 13 ('clean', 'Clean'), |
40 enclosure_url = models.URLField(verify_exists=False) | 45 enclosure_url = models.URLField(verify_exists=False) |
41 alt_enclosure_url = models.URLField(verify_exists=False, blank=True) | 46 alt_enclosure_url = models.URLField(verify_exists=False, blank=True) |
42 enclosure_length = models.IntegerField() | 47 enclosure_length = models.IntegerField() |
43 enclosure_type = models.CharField(max_length=32) | 48 enclosure_type = models.CharField(max_length=32) |
44 guid = models.CharField(max_length=255) | 49 guid = models.CharField(max_length=255) |
45 pubdate = models.DateTimeField() | 50 pubdate = models.DateTimeField(db_index=True) |
46 duration = models.CharField(max_length=16) | 51 duration = models.CharField(max_length=16) |
47 keywords = models.CharField(max_length=255) | 52 keywords = models.CharField(max_length=255) |
48 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) | 53 explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) |
54 update_date = models.DateTimeField(db_index=True, blank=True) | |
49 | 55 |
50 @models.permalink | 56 @models.permalink |
51 def get_absolute_url(self): | 57 def get_absolute_url(self): |
52 return ('podcast.views.detail', [str(self.id)]) | 58 return ('podcast.views.detail', [str(self.id)]) |
53 | 59 |
57 class Meta: | 63 class Meta: |
58 ordering = ('-pubdate', ) | 64 ordering = ('-pubdate', ) |
59 verbose_name = 'podcast' | 65 verbose_name = 'podcast' |
60 verbose_name_plural = 'podcasts' | 66 verbose_name_plural = 'podcasts' |
61 | 67 |
68 def save(self, *args, **kwargs): | |
69 if not self.id: | |
70 if not self.pubdate: | |
71 self.pubdate = datetime.datetime.now() | |
72 self.update_date = self.pubdate | |
73 else: | |
74 self.update_date = datetime.datetime.now() | |
75 super(Item, self).save(*args, **kwargs) | |
76 | |
62 def search_title(self): | 77 def search_title(self): |
63 return "%s: %s" % (self.title, self.subtitle) | 78 return "%s: %s" % (self.title, self.subtitle) |
64 | 79 |
65 def search_summary(self): | 80 def search_summary(self): |
66 return u"\n".join((self.subtitle, self.summary, self.keywords)) | 81 return u"\n".join((self.subtitle, self.summary, self.keywords)) |