Fixed #1981 -- Fixed bug in feeds.py for comments
git-svn-id: http://code.djangoproject.com/svn/django/trunk@2983 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
d4f69f8fe9
commit
fd16f1468a
|
@ -5,7 +5,7 @@ from django.core.exceptions import ObjectDoesNotExist
|
||||||
from django.contrib.sites.models import Site
|
from django.contrib.sites.models import Site
|
||||||
|
|
||||||
class LatestFreeCommentsFeed(Feed):
|
class LatestFreeCommentsFeed(Feed):
|
||||||
"""Feed of latest comments on the current site"""
|
"Feed of latest comments on the current site."
|
||||||
|
|
||||||
comments_class = FreeComment
|
comments_class = FreeComment
|
||||||
|
|
||||||
|
@ -25,24 +25,18 @@ class LatestFreeCommentsFeed(Feed):
|
||||||
return "Latest comments on %s" % self._site.name
|
return "Latest comments on %s" % self._site.name
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
return self.comments_class.objects.filter(**self._get_lookup_kwargs())
|
return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)[:40]
|
||||||
|
|
||||||
def _get_lookup_kwargs(self):
|
|
||||||
return {
|
|
||||||
'site__pk': settings.SITE_ID,
|
|
||||||
'is_public__exact': True,
|
|
||||||
'limit': 40,
|
|
||||||
}
|
|
||||||
|
|
||||||
class LatestCommentsFeed(LatestFreeCommentsFeed):
|
class LatestCommentsFeed(LatestFreeCommentsFeed):
|
||||||
"""Feed of latest free comments on the current site"""
|
"""Feed of latest free comments on the current site"""
|
||||||
|
|
||||||
comments_class = Comment
|
comments_class = Comment
|
||||||
|
|
||||||
def _get_lookup_kwargs(self):
|
def items(self):
|
||||||
kwargs = LatestFreeCommentsFeed._get_lookup_kwargs(self)
|
qs = LatestFreeCommentsFeed.items(self)
|
||||||
kwargs['is_removed__exact'] = False
|
qs = qs.filter(is_removed=False)
|
||||||
if settings.COMMENTS_BANNED_USERS_GROUP:
|
if settings.COMMENTS_BANNED_USERS_GROUP:
|
||||||
kwargs['where'] = ['user_id NOT IN (SELECT user_id FROM auth_users_group WHERE group_id = %s)']
|
where = ['user_id NOT IN (SELECT user_id FROM auth_users_group WHERE group_id = %s)']
|
||||||
kwargs['params'] = [COMMENTS_BANNED_USERS_GROUP]
|
params = [COMMENTS_BANNED_USERS_GROUP]
|
||||||
return kwargs
|
qs = qs.extra(where=where, params=params)
|
||||||
|
return qs
|
||||||
|
|
Loading…
Reference in New Issue