Mercurial > public > sg101
comparison gpp/forums/models.py @ 98:d0d779dd0832
Forums: flag posts.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 13 Sep 2009 21:45:35 +0000 |
parents | 96eec1ed0fd3 |
children | eb9f99382476 |
comparison
equal
deleted
inserted
replaced
97:96eec1ed0fd3 | 98:d0d779dd0832 |
---|---|
143 first_post_id = self.topic.posts.all()[0].id | 143 first_post_id = self.topic.posts.all()[0].id |
144 super(Post, self).delete(*args, **kwargs) | 144 super(Post, self).delete(*args, **kwargs) |
145 if self.id == first_post_id: | 145 if self.id == first_post_id: |
146 self.topic.delete() | 146 self.topic.delete() |
147 | 147 |
148 | |
149 class FlaggedPost(models.Model): | |
150 """This model represents a user flagging a post as inappropriate.""" | |
151 user = models.ForeignKey(User) | |
152 post = models.ForeignKey(Post) | |
153 flag_date = models.DateTimeField(auto_now_add=True) | |
154 | |
155 def __unicode__(self): | |
156 return u'Post ID %s flagged by %s' % (self.post.id, self.user.username) | |
157 | |
158 class Meta: | |
159 ordering = ('flag_date', ) | |
160 | |
161 def get_post_url(self): | |
162 return '<a href="%s">Post</a>' % self.post.get_absolute_url() | |
163 get_post_url.allow_tags = True | |
164 | |
148 # TODO: A "read" table | 165 # TODO: A "read" table |
149 # TODO: A flagged post table |