1 from django
.conf
import settings
2 from django
.contrib
.syndication
.views
import Feed
3 from django
.contrib
.sites
.models
import Site
4 from django
.contrib
import comments
5 from django
.utils
.translation
import ugettext
as _
7 class LatestCommentFeed(Feed
):
8 """Feed of latest comments on the current site."""
11 if not hasattr(self
, '_site'):
12 self
._site
= Site
.objects
.get_current()
13 return _("%(site_name)s comments") % dict(site_name
=self
._site
.name
)
16 if not hasattr(self
, '_site'):
17 self
._site
= Site
.objects
.get_current()
18 return "http://%s/" % (self
._site
.domain
)
20 def description(self
):
21 if not hasattr(self
, '_site'):
22 self
._site
= Site
.objects
.get_current()
23 return _("Latest comments on %(site_name)s") % dict(site_name
=self
._site
.name
)
26 qs
= comments
.get_model().objects
.filter(
27 site__pk
= settings
.SITE_ID
,
31 return qs
.order_by('-submit_date')[:40]
33 def item_pubdate(self
, item
):
34 return item
.submit_date