Fixed #4404 -- Fixed LatestCommentsFeed query problem. Thanks, SmileyChris.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5408 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2007-06-01 11:58:17 +00:00
parent 63a1304f54
commit 8728e0f353
1 changed files with 6 additions and 3 deletions

View File

@ -23,16 +23,19 @@ class LatestFreeCommentsFeed(Feed):
self._site = Site.objects.get_current() self._site = Site.objects.get_current()
return "Latest comments on %s" % self._site.name return "Latest comments on %s" % self._site.name
def get_query_set(self):
return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)
def items(self): def items(self):
return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)[:40] return self.get_query_set()[: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 items(self): def get_query_set(self):
qs = LatestFreeCommentsFeed.items(self) qs = super(LatestCommentsFeed, self).get_query_set()
qs = qs.filter(is_removed=False) qs = qs.filter(is_removed=False)
if settings.COMMENTS_BANNED_USERS_GROUP: if settings.COMMENTS_BANNED_USERS_GROUP:
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)']