diff gpp/forums/models.py @ 115:0ce0104c7df3

Forums: split topic.
author Brian Neal <bgneal@gmail.com>
date Thu, 22 Oct 2009 02:57:18 +0000
parents d97ceb95ce02
children 19b64e8f02a2
line wrap: on
line diff
--- a/gpp/forums/models.py	Sun Oct 11 20:27:07 2009 +0000
+++ b/gpp/forums/models.py	Thu Oct 22 02:57:18 2009 +0000
@@ -228,7 +228,7 @@
     topic = models.ForeignKey(Topic, related_name='posts')
     user = models.ForeignKey(User, related_name='posts')
     creation_date = models.DateTimeField(auto_now_add=True)
-    update_date = models.DateTimeField(auto_now=True)
+    update_date = models.DateTimeField(null=True)
     body = models.TextField()
     html = models.TextField()
     user_ip = models.IPAddressField(blank=True, default='', null=True)
@@ -262,7 +262,11 @@
             self.topic.delete()
 
     def has_been_edited(self):
-        return (self.update_date - self.creation_date) > POST_EDIT_DELTA
+        return self.update_date is not None
+
+    def touch(self):
+        """Call this function to indicate the post has been edited."""
+        self.update_date = datetime.datetime.now()
 
 
 class FlaggedPost(models.Model):
@@ -327,7 +331,7 @@
                 self.last_visit.strftime('%Y-%m-%d %H:%M:%S'))
 
     def save(self, *args, **kwargs):
-        if self.id is None:
+        if self.id is one:
             self.touch()
         super(TopicLastVisit, self).save(*args, **kwargs)