Ticket #6437: karmacounting.diff
File karmacounting.diff, 1.1 KB (added by , 17 years ago) |
---|
-
django/contrib/comments/models.py
49 49 """ 50 50 extra_kwargs = {} 51 51 extra_kwargs.setdefault('select', {}) 52 extra_kwargs['select']['_karma_total_good'] = 'SELECT COUNT(*) FROM comments_karmascore, comments_comment WHERE comments_karmascore.comment_id=comments_comment.id AND score=1'53 extra_kwargs['select']['_karma_total_bad'] = 'SELECT COUNT(*) FROM comments_karmascore, comments_comment WHERE comments_karmascore.comment_id=comments_comment.id AND score=-1'54 52 return self.filter(**kwargs).extra(**extra_kwargs) 55 53 56 54 def user_is_moderator(self, user): … … 136 134 def _fill_karma_cache(self): 137 135 "Helper function that populates good/bad karma caches" 138 136 good, bad = 0, 0 139 for k in self.karmascore_set :137 for k in self.karmascore_set.all(): 140 138 if k.score == -1: 141 139 bad +=1 142 140 elif k.score == 1: