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."""
10 if not hasattr(self
, '_site'):
11 self
._site
= Site
.objects
.get_current()
12 return u
"%s comments" % self
._site
.name
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
25 qs
= comments
.get_model().objects
.filter(
26 site__pk
= settings
.SITE_ID
,
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