Fixes an issue where the organization home page would throw a 505 when no projects...
[Melange.git] / app / django / contrib / comments / feeds.py
blob418680a5f197bbe141b27f7083b5fd2a53348258
1 from django.conf import settings
2 from django.contrib.syndication.feeds import Feed
3 from django.contrib.sites.models import Site
4 from django.contrib import comments
6 class LatestCommentFeed(Feed):
7 """Feed of latest comments on the current site."""
9 def title(self):
10 if not hasattr(self, '_site'):
11 self._site = Site.objects.get_current()
12 return u"%s comments" % self._site.name
14 def link(self):
15 if not hasattr(self, '_site'):
16 self._site = Site.objects.get_current()
17 return "http://%s/" % (self._site.domain)
19 def description(self):
20 if not hasattr(self, '_site'):
21 self._site = Site.objects.get_current()
22 return u"Latest comments on %s" % self._site.name
24 def items(self):
25 qs = comments.get_model().objects.filter(
26 site__pk = settings.SITE_ID,
27 is_public = True,
28 is_removed = False,
30 if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
31 where = ['user_id NOT IN (SELECT user_id FROM auth_user_groups WHERE group_id = %s)']
32 params = [settings.COMMENTS_BANNED_USERS_GROUP]
33 qs = qs.extra(where=where, params=params)
34 return qs.order_by('-submit_date')[:40]
36 def item_pubdate(self, item):
37 return item.submit_date