Commits

Cédric Bonhomme committed 73cc481

Added main comments feed (RSS and ATOM).

  • Participants
  • Parent commits 0c3a376

Comments (0)

Files changed (4)

 
 
     def __unicode__(self):
-        return unicode("%s: %s" % (self.post, self.content[:60]))
+        return unicode("%s: %s" % (self.post.title, self.content[:60]))
 
 
 class Category(models.Model):
 from django.contrib.syndication.views import Feed
 
 from cedricbonhomme.blog.models import Post
+from cedricbonhomme.blog.models import Comment
 
 class RssSiteNewsFeed(Feed):
     """
     """
     feed_type = Atom1Feed
     subtitle = RssSiteNewsFeed.description
+
+
+
+class RssCommentsFeed(Feed):
+    """
+    """
+    title = "~/blog"
+    link = "/"
+    description = "Latest comments from the blog of Cédric Bonhomme."
+
+    def items(self):
+        return Comment.objects.order_by('-created')[:15]
+
+    def item_description(self, item):
+        return item.content
+
+    def item_link(self, item):
+        return self.link + str(item.post.id)
+
+class AtomCommentsFeed(RssCommentsFeed):
+    """
+    """
+    feed_type = Atom1Feed
+    subtitle = RssCommentsFeed.description
     'django.contrib.sites',
     'django.contrib.messages',
     'django.contrib.staticfiles',
+    'django.contrib.admin',
     'cedricbonhomme.blog'
     # Uncomment the next line to enable the admin:
-    'django.contrib.admin',
+    # 'django.contrib.admin',
     # Uncomment the next line to enable admin documentation:
     # 'django.contrib.admindocs',
 )
 # -*- coding: utf-8 -*-
 from django.conf.urls.defaults import patterns, include, url
 
-from cedricbonhomme.feeds import RssSiteNewsFeed, AtomSiteNewsFeed
+from cedricbonhomme.feeds import RssSiteNewsFeed, AtomSiteNewsFeed, RssCommentsFeed, AtomCommentsFeed
 
 # Uncomment the next two lines to enable the admin:
 from django.contrib import admin
 
     (r'^feed/rss/$', RssSiteNewsFeed()),
     (r'^feed/atom/$', AtomSiteNewsFeed()),
+    (r'^comments/feed/rss/$', RssCommentsFeed()),
+    (r'^comments/feed/atom/$', AtomCommentsFeed()),
 
     # Uncomment the admin/doc line below to enable admin documentation:
     # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),