Implement automatic comment moderation queue in Django
Assuming you're using latest trunk (i.e., post-magic-removal merge), you need a few things:
1. A method on your content object which returns whether a comment should go to moderation or not.
2. A method on the FreeComment model which checks this and sets the 'approved' field appropriately.
3. A list filter for the FreeComment admin to show comments in need of moderation.
For the first bit, we borrow from my method for automatically closing comments (http://textsnippets.com/posts/show/266):
This returns False if the object is less than 30 days old, True if it's 30 days old or older.
For the second bit, you'll need to hack on the FreeComment model; it's located in django/contrib/comments/models.py. Add this:
And for the third bit, just add 'approved' to the list of properties the admin can filter on, and you'll be able to click and get a list of all comments which have not yet been approved.
In your templates, you can then manually check whether each comment is approved or not with {% if comment.approved %} or, if you're feeling adventurous, you can add a custom manager to the FreeComment model which only returns comments which have been approved.
1. A method on your content object which returns whether a comment should go to moderation or not.
2. A method on the FreeComment model which checks this and sets the 'approved' field appropriately.
3. A list filter for the FreeComment admin to show comments in need of moderation.
For the first bit, we borrow from my method for automatically closing comments (http://textsnippets.com/posts/show/266):
def auto_moderate(self): return datetime.datetime.today() - datetime.timedelta(30) >= self.pub_date
This returns False if the object is less than 30 days old, True if it's 30 days old or older.
For the second bit, you'll need to hack on the FreeComment model; it's located in django/contrib/comments/models.py. Add this:
def save(self): if self.get_content_object().auto_moderate: self.approved = False super(FreeComment, self).save()
And for the third bit, just add 'approved' to the list of properties the admin can filter on, and you'll be able to click and get a list of all comments which have not yet been approved.
In your templates, you can then manually check whether each comment is approved or not with {% if comment.approved %} or, if you're feeling adventurous, you can add a custom manager to the FreeComment model which only returns comments which have been approved.