Mercurial > public > sg101
diff gpp/forums/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 | dcc929973bba |
children | 8fd4984d5c3b |
line wrap: on
line diff
--- a/gpp/forums/models.py Thu Sep 30 00:06:04 2010 +0000 +++ b/gpp/forums/models.py Sat Oct 02 23:24:39 2010 +0000 @@ -243,8 +243,8 @@ """ 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(null=True) + creation_date = models.DateTimeField(db_index=True) + update_date = models.DateTimeField(db_index=True) body = models.TextField() html = models.TextField() user_ip = models.IPAddressField(blank=True, default='', null=True) @@ -269,6 +269,10 @@ return self.summary() def save(self, *args, **kwargs): + if not self.id: + self.creation_date = datetime.datetime.now() + self.update_date = self.creation_date + self.html = site_markup(self.body) super(Post, self).save(*args, **kwargs) @@ -279,7 +283,7 @@ self.topic.delete() def has_been_edited(self): - return self.update_date is not None + return self.update_date > self.creation_date def touch(self): """Call this function to indicate the post has been edited."""