Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit fd16f1468a0c5825bdd631e9a223601d65f429fb 1 parent d4f69f8
Adrian Holovaty authored May 26, 2006

Showing 1 changed file with 9 additions and 15 deletions. Show diff stats Hide diff stats

  1. 24  django/contrib/comments/feeds.py
24  django/contrib/comments/feeds.py
@@ -5,7 +5,7 @@
5 5
 from django.contrib.sites.models import Site
6 6
 
7 7
 class LatestFreeCommentsFeed(Feed):
8  
-    """Feed of latest comments on the current site"""
  8
+    "Feed of latest comments on the current site."
9 9
 
10 10
     comments_class = FreeComment
11 11
 
@@ -25,24 +25,18 @@ def description(self):
25 25
         return "Latest comments on %s" % self._site.name
26 26
 
27 27
     def items(self):
28  
-        return self.comments_class.objects.filter(**self._get_lookup_kwargs())
29  
-
30  
-    def _get_lookup_kwargs(self):
31  
-        return {
32  
-            'site__pk': settings.SITE_ID,
33  
-            'is_public__exact': True,
34  
-            'limit': 40,
35  
-        }
  28
+        return self.comments_class.objects.filter(site__pk=settings.SITE_ID, is_public=True)[:40]
36 29
 
37 30
 class LatestCommentsFeed(LatestFreeCommentsFeed):
38 31
     """Feed of latest free comments on the current site"""
39 32
 
40 33
     comments_class = Comment
41 34
 
42  
-    def _get_lookup_kwargs(self):
43  
-        kwargs = LatestFreeCommentsFeed._get_lookup_kwargs(self)
44  
-        kwargs['is_removed__exact'] = False
  35
+    def items(self):
  36
+        qs = LatestFreeCommentsFeed.items(self)
  37
+        qs = qs.filter(is_removed=False)
45 38
         if settings.COMMENTS_BANNED_USERS_GROUP:
46  
-            kwargs['where'] = ['user_id NOT IN (SELECT user_id FROM auth_users_group WHERE group_id = %s)']
47  
-            kwargs['params'] = [COMMENTS_BANNED_USERS_GROUP]
48  
-        return kwargs
  39
+            where = ['user_id NOT IN (SELECT user_id FROM auth_users_group WHERE group_id = %s)']
  40
+            params = [COMMENTS_BANNED_USERS_GROUP]
  41
+            qs = qs.extra(where=where, params=params)
  42
+        return qs

0 notes on commit fd16f14

Please sign in to comment.
Something went wrong with that request. Please try again.