2005-11-19 00:20:26 +08:00
|
|
|
from django.conf import settings
|
|
|
|
from django.contrib.syndication.feeds import Feed
|
2006-05-02 09:31:56 +08:00
|
|
|
from django.contrib.sites.models import Site
|
2008-08-26 06:14:22 +08:00
|
|
|
from django.contrib import comments
|
2005-11-19 00:20:26 +08:00
|
|
|
|
2008-08-26 06:14:22 +08:00
|
|
|
class LatestCommentFeed(Feed):
|
|
|
|
"""Feed of latest comments on the current site."""
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2005-11-19 00:20:26 +08:00
|
|
|
def title(self):
|
|
|
|
if not hasattr(self, '_site'):
|
2006-05-02 09:31:56 +08:00
|
|
|
self._site = Site.objects.get_current()
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
return u"%s comments" % self._site.name
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2005-11-19 00:20:26 +08:00
|
|
|
def link(self):
|
|
|
|
if not hasattr(self, '_site'):
|
2006-05-02 09:31:56 +08:00
|
|
|
self._site = Site.objects.get_current()
|
2005-11-19 00:20:26 +08:00
|
|
|
return "http://%s/" % (self._site.domain)
|
2006-05-02 09:31:56 +08:00
|
|
|
|
2005-11-19 00:20:26 +08:00
|
|
|
def description(self):
|
|
|
|
if not hasattr(self, '_site'):
|
2006-05-02 09:31:56 +08:00
|
|
|
self._site = Site.objects.get_current()
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
return u"Latest comments on %s" % self._site.name
|
2005-11-19 00:20:26 +08:00
|
|
|
|
|
|
|
def items(self):
|
2008-08-26 06:14:22 +08:00
|
|
|
qs = comments.get_model().objects.filter(
|
|
|
|
site__pk = settings.SITE_ID,
|
|
|
|
is_public = True,
|
|
|
|
is_removed = False,
|
|
|
|
)
|
|
|
|
if getattr(settings, 'COMMENTS_BANNED_USERS_GROUP', None):
|
2006-05-26 12:21:36 +08:00
|
|
|
where = ['user_id NOT IN (SELECT user_id FROM auth_users_group WHERE group_id = %s)']
|
2006-07-22 03:12:51 +08:00
|
|
|
params = [settings.COMMENTS_BANNED_USERS_GROUP]
|
2006-05-26 12:21:36 +08:00
|
|
|
qs = qs.extra(where=where, params=params)
|
2008-08-26 06:14:22 +08:00
|
|
|
return qs[:40]
|
|
|
|
|
|
|
|
def item_pubdate(self, item):
|
|
|
|
return item.submit_date
|