Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit e2cff236b61a072e6e75a7dfaf86f0603449c263 1 parent b42de7e
@Fantomas42 authored
Showing with 9 additions and 7 deletions.
  1. +8 −6 zinnia/signals.py
  2. +1 −1  zinnia/tests/moderator.py
View
14 zinnia/signals.py
@@ -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):
View
2  zinnia/tests/moderator.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.