Ticket #1709: comments.diff

File comments.diff, 2.0 KB (added by EricHsu, 18 years ago)

patch for updating the comments module's view/model

  • models.py

     
    4747        Returns a list of Comment objects matching the given lookup terms, with
    4848        _karma_total_good and _karma_total_bad filled.
    4949        """
    50         kwargs.setdefault('select', {})
    51         kwargs['select']['_karma_total_good'] = 'SELECT COUNT(*) FROM comments_karmascore WHERE comments_karmascore.comment_id=comments.id AND score=1'
    52         kwargs['select']['_karma_total_bad'] = 'SELECT COUNT(*) FROM comments_karmascore WHERE comments_karmascore.comment_id=comments.id AND score=-1'
    53         return self.filter(**kwargs)
     50        extra_kwargs = {}
     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        return self.filter(**kwargs).extra(**extra_kwargs)
    5455
    5556    def user_is_moderator(self, user):
    5657        if user.is_superuser:
  • views/comments.py

     
    108108        c.save()
    109109        # If the commentor has posted fewer than COMMENTS_FIRST_FEW comments,
    110110        # send the comment to the managers.
    111         if self.user_cache.get_comments_comment_count() <= settings.COMMENTS_FIRST_FEW:
     111        if self.user_cache.comment_set.count() <= settings.COMMENTS_FIRST_FEW:
    112112            message = ngettext('This comment was posted by a user who has posted fewer than %(count)s comment:\n\n%(text)s',
    113113                'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s') % \
    114114                {'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
Back to Top