summaryrefslogtreecommitdiff
path: root/app/django_comments/feeds.py
diff options
context:
space:
mode:
authorluxagraf <sng@luxagraf.net>2019-05-05 11:40:42 -0500
committerluxagraf <sng@luxagraf.net>2019-05-05 11:40:42 -0500
commita2891841fbf1e5660693a1f9109f2e6810224a3b (patch)
treebe0aae73fe8f5e6271a76e8c5c6dc35b00f347a6 /app/django_comments/feeds.py
parentbdc06f56d538358f1fa07d35afb5733c790e3ab2 (diff)
added tutorials with commentsHEADmaster
Diffstat (limited to 'app/django_comments/feeds.py')
-rw-r--r--app/django_comments/feeds.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/app/django_comments/feeds.py b/app/django_comments/feeds.py
new file mode 100644
index 0000000..bc8c501
--- /dev/null
+++ b/app/django_comments/feeds.py
@@ -0,0 +1,33 @@
+from django.contrib.sites.shortcuts import get_current_site
+from django.contrib.syndication.views import Feed
+from django.utils.translation import ugettext as _
+
+import django_comments
+
+
+class LatestCommentFeed(Feed):
+ """Feed of latest comments on the current site."""
+
+ def __call__(self, request, *args, **kwargs):
+ self.site = get_current_site(request)
+ return super(LatestCommentFeed, self).__call__(request, *args, **kwargs)
+
+ def title(self):
+ return _("%(site_name)s comments") % dict(site_name=self.site.name)
+
+ def link(self):
+ return "http://%s/" % (self.site.domain)
+
+ def description(self):
+ return _("Latest comments on %(site_name)s") % dict(site_name=self.site.name)
+
+ def items(self):
+ qs = django_comments.get_model().objects.filter(
+ site__pk=self.site.pk,
+ is_public=True,
+ is_removed=False,
+ )
+ return qs.order_by('-submit_date')[:40]
+
+ def item_pubdate(self, item):
+ return item.submit_date