Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- a/gpp/podcast/models.py Thu Sep 30 00:06:04 2010 +0000 +++ b/gpp/podcast/models.py Sat Oct 02 23:24:39 2010 +0000 @@ -1,7 +1,12 @@ -"""Models for the podcast application.""" +""" +Models for the podcast application. + +""" +import datetime from django.db import models + EXPLICIT_CHOICES = ( ('yes', 'Yes'), ('no', 'No'), @@ -42,10 +47,11 @@ enclosure_length = models.IntegerField() enclosure_type = models.CharField(max_length=32) guid = models.CharField(max_length=255) - pubdate = models.DateTimeField() + pubdate = models.DateTimeField(db_index=True) duration = models.CharField(max_length=16) keywords = models.CharField(max_length=255) explicit = models.CharField(max_length=8, choices=EXPLICIT_CHOICES) + update_date = models.DateTimeField(db_index=True, blank=True) @models.permalink def get_absolute_url(self): @@ -59,6 +65,15 @@ verbose_name = 'podcast' verbose_name_plural = 'podcasts' + def save(self, *args, **kwargs): + if not self.id: + if not self.pubdate: + self.pubdate = datetime.datetime.now() + self.update_date = self.pubdate + else: + self.update_date = datetime.datetime.now() + super(Item, self).save(*args, **kwargs) + def search_title(self): return "%s: %s" % (self.title, self.subtitle)