Mercurial > public > sg101
diff gpp/forums/models.py @ 83:5b4c812b448e
Forums: Added the ability to add a new topic. This is very much a work in progress.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 29 Aug 2009 20:54:16 +0000 |
parents | bc3978f023c2 |
children | 62af8cd8f57b |
line wrap: on
line diff
--- a/gpp/forums/models.py Sun Aug 23 04:04:29 2009 +0000 +++ b/gpp/forums/models.py Sat Aug 29 20:54:16 2009 +0000 @@ -99,6 +99,15 @@ self.last_post = None self.update_date = self.creation_date + def reply_count(self): + """ + Returns the number of replies to a topic. The first post + doesn't count as a reply. + """ + if self.post_count > 1: + return self.post_count - 1 + return 0 + class Post(models.Model): topic = models.ForeignKey(Topic, related_name='posts') @@ -107,7 +116,7 @@ update_date = models.DateTimeField(auto_now=True) body = models.TextField() html = models.TextField() - user_ip = models.IPAddressField(blank=True, default='') + user_ip = models.IPAddressField(blank=True, default='', null=True) class Meta: ordering = ('creation_date', )