diff gpp/news/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 1246a4f1ab4f
children 53fdaf0da539
line wrap: on
line diff
--- a/gpp/news/models.py	Thu Sep 30 00:06:04 2010 +0000
+++ b/gpp/news/models.py	Sat Oct 02 23:24:39 2010 +0000
@@ -36,6 +36,7 @@
     allow_comments = models.BooleanField(default=True)
     tags = TagField()
     front_page_expiration = models.DateField(null=True, blank=True)
+    update_date = models.DateTimeField(db_index=True, blank=True)
 
     class Meta:
         abstract = True
@@ -46,7 +47,11 @@
 
     def save(self, *args, **kwargs):
         if not self.pk:
-            self.date_submitted = datetime.datetime.now()
+            if not self.date_submitted:
+                self.date_submitted = datetime.datetime.now()
+            self.update_date = self.date_submitted
+        else:
+            self.update_date = datetime.datetime.now()
 
         super(PendingStory, self).save(*args, **kwargs)
 
@@ -73,6 +78,15 @@
         verbose_name = 'news story'
         verbose_name_plural = 'news stories'
 
+    def save(self, *args, **kwargs):
+        if not self.pk:
+            self.date_submitted = datetime.datetime.now()
+            self.update_date = self.date_submitted
+        else:
+            self.update_date = datetime.datetime.now()
+
+        super(Story, self).save(*args, **kwargs)
+
     def can_comment_on(self):
         now = datetime.datetime.now()
         delta = now - self.date_submitted