comment moderation can't work with customized comment
Hi all,
The generic comment moderation worked as expected in my application while using the default comment model. Moderation stopped setting ``is_public`` to ``0`` when I customized the build-in comment app by adding a title field as the dev doc said.
Here is the code.
models.py
class Post(models.Model):
#...
class PostModerator(CommentModerator):
email_notification = True
enable_field = 'enable_comments'
auto_moderate_field = 'date_created'
moderate_after = 0
def moderate(self, comment, content_object, request):
#...
return True
moderator.register(Post, PostModerator)
class CommentWithTitle(Comment):
title = models.CharField(max_length=300)
forms.py
class CommentFormWithTitle(CommentForm):
def get_comment_model(self):
return CommentWithTitle
def get_comment_create_data(self):
data = super(CommentFormWithTitle, self).get_comment_create_data()
data['title'] = self.cleaned_data['title']
return data
__init__.py
def get_model():
return CommentWithTitle
def get_form():
return CommentFormWithTitle
settings.py
INSTALLED_APPS = (
#...
'mycomment',
)
COMMENTS_APP = 'mycomment'
Comment to post can be saved but can't be moderated. Did I make something wrong?
Thanks.
-- You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/kzuT4koXrEcJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home