Permalink
Browse files

Fix issue on Entry.comment_count when a non public comment is posted

  • Loading branch information...
1 parent b42de7e commit e2cff236b61a072e6e75a7dfaf86f0603449c263 @Fantomas42 committed May 3, 2013
Showing with 9 additions and 7 deletions.
  1. +8 −6 zinnia/signals.py
  2. +1 −1 zinnia/tests/moderator.py
View
@@ -92,12 +92,14 @@ def count_discussions_handler(sender, **kwargs):
def count_comments_handler(sender, **kwargs):
"""
- Update Entry.comment_count when a comment was posted.
- """
- entry = kwargs['comment'].content_object
- if isinstance(entry, Entry):
- entry.comment_count = F('comment_count') + 1
- entry.save(update_fields=['comment_count'])
+ Update Entry.comment_count when a public comment was posted.
+ """
+ comment = kwargs['comment']
+ if comment.is_public:
+ entry = comment.content_object
+ if isinstance(entry, Entry):
+ entry.comment_count = F('comment_count') + 1
+ entry.save(update_fields=['comment_count'])
def count_pingbacks_handler(sender, **kwargs):
@@ -183,4 +183,4 @@ class AllIsSpamModerator(EntryCommentModerator):
disconnect_discussion_signals()
self.assertEqual(comments.get_model().objects.count(), 1)
entry = Entry.objects.get(pk=self.entry.pk)
- self.assertEquals(entry.comment_count, 1)
+ self.assertEquals(entry.comment_count, 0)

0 comments on commit e2cff23

Please sign in to comment.