diff 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
line wrap: on
line diff
--- a/gpp/forums/models.py	Sun Sep 13 19:58:31 2009 +0000
+++ b/gpp/forums/models.py	Sun Sep 13 21:45:35 2009 +0000
@@ -145,5 +145,21 @@
         if self.id == first_post_id:
             self.topic.delete()
 
+
+class FlaggedPost(models.Model):
+    """This model represents a user flagging a post as inappropriate."""
+    user = models.ForeignKey(User)
+    post = models.ForeignKey(Post)
+    flag_date = models.DateTimeField(auto_now_add=True)
+
+    def __unicode__(self):
+        return u'Post ID %s flagged by %s' % (self.post.id, self.user.username)
+
+    class Meta:
+        ordering = ('flag_date', )
+
+    def get_post_url(self):
+        return '<a href="%s">Post</a>' % self.post.get_absolute_url()
+    get_post_url.allow_tags = True
+
 # TODO: A "read" table
-# TODO: A flagged post table