mirror of
https://github.com/django/django.git
synced 2025-07-06 18:59:13 +00:00
magic-removal: Fixed #1709 -- Updated comments app to use magic-removal APIs. Thanks, Eric Hsu
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2775 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
f4eb6b118a
commit
b4e85c7d1c
@ -47,10 +47,11 @@ class CommentManager(models.Manager):
|
|||||||
Returns a list of Comment objects matching the given lookup terms, with
|
Returns a list of Comment objects matching the given lookup terms, with
|
||||||
_karma_total_good and _karma_total_bad filled.
|
_karma_total_good and _karma_total_bad filled.
|
||||||
"""
|
"""
|
||||||
kwargs.setdefault('select', {})
|
extra_kwargs = {}
|
||||||
kwargs['select']['_karma_total_good'] = 'SELECT COUNT(*) FROM comments_karmascore WHERE comments_karmascore.comment_id=comments.id AND score=1'
|
extra_kwargs.setdefault('select', {})
|
||||||
kwargs['select']['_karma_total_bad'] = 'SELECT COUNT(*) FROM comments_karmascore WHERE comments_karmascore.comment_id=comments.id AND score=-1'
|
extra_kwargs['select']['_karma_total_good'] = 'SELECT COUNT(*) FROM comments_karmascore, comments_comment WHERE comments_karmascore.comment_id=comments_comment.id AND score=1'
|
||||||
return self.filter(**kwargs)
|
extra_kwargs['select']['_karma_total_bad'] = 'SELECT COUNT(*) FROM comments_karmascore, comments_comment WHERE comments_karmascore.comment_id=comments_comment.id AND score=-1'
|
||||||
|
return self.filter(**kwargs).extra(**extra_kwargs)
|
||||||
|
|
||||||
def user_is_moderator(self, user):
|
def user_is_moderator(self, user):
|
||||||
if user.is_superuser:
|
if user.is_superuser:
|
||||||
|
@ -108,7 +108,7 @@ class PublicCommentManipulator(AuthenticationForm):
|
|||||||
c.save()
|
c.save()
|
||||||
# If the commentor has posted fewer than COMMENTS_FIRST_FEW comments,
|
# If the commentor has posted fewer than COMMENTS_FIRST_FEW comments,
|
||||||
# send the comment to the managers.
|
# send the comment to the managers.
|
||||||
if self.user_cache.get_comments_comment_count() <= settings.COMMENTS_FIRST_FEW:
|
if self.user_cache.comment_set.count() <= settings.COMMENTS_FIRST_FEW:
|
||||||
message = ngettext('This comment was posted by a user who has posted fewer than %(count)s comment:\n\n%(text)s',
|
message = ngettext('This comment was posted by a user who has posted fewer than %(count)s comment:\n\n%(text)s',
|
||||||
'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s') % \
|
'This comment was posted by a user who has posted fewer than %(count)s comments:\n\n%(text)s') % \
|
||||||
{'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
|
{'count': settings.COMMENTS_FIRST_FEW, 'text': c.get_as_text()}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user