Ticket #6437: karmacounting.diff

File karmacounting.diff, 1.1 KB (added by Naoki Hiroshima, 17 years ago)
  • django/contrib/comments/models.py

     
    4949        """
    5050        extra_kwargs = {}
    5151        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'
    5452        return self.filter(**kwargs).extra(**extra_kwargs)
    5553
    5654    def user_is_moderator(self, user):
     
    136134    def _fill_karma_cache(self):
    137135        "Helper function that populates good/bad karma caches"
    138136        good, bad = 0, 0
    139         for k in self.karmascore_set:
     137        for k in self.karmascore_set.all():
    140138            if k.score == -1:
    141139                bad +=1
    142140            elif k.score == 1:
Back to Top