diff gpp/news/feeds.py @ 170:6f14970b103a

Implement #52 Forums RSS feeds.
author Brian Neal <bgneal@gmail.com>
date Thu, 11 Feb 2010 02:29:03 +0000
parents dbd703f7d63a
children b7ac381996e8
line wrap: on
line diff
--- a/gpp/news/feeds.py	Sun Jan 31 04:52:08 2010 +0000
+++ b/gpp/news/feeds.py	Thu Feb 11 02:29:03 2010 +0000
@@ -1,28 +1,40 @@
 """
 This file contains the feed classes for the news application.
 """
+import datetime
 
 from django.contrib.syndication.feeds import Feed
+
 from news.models import Story
 
+BASE_YEAR = 2010
+
 
 class LatestNewsFeed(Feed):
-   """The Feed class for the news application"""
+    """The Feed class for the news application"""
 
-   title = 'SurfGuitar101.com News Feed'
-   link = '/feeds/news/'
-   description = 'News articles and stories from SurfGuitar101.com'
-   copyright = 'Copyright (C) 2008, Brian Neal'
-   ttl = '720'
+    title = 'SurfGuitar101.com News Feed'
+    link = '/feeds/news/'
+    description = 'News articles and stories from SurfGuitar101.com'
+    ttl = '720'
 
-   title_template = 'news/feed_title.html'
-   description_template = 'news/feed_description.html'
-   
-   def items(self):
-      return Story.objects.order_by('-date_published')[:5]
+    title_template = 'news/feed_title.html'
+    description_template = 'news/feed_description.html'
 
-   def item_pubdate(self, item):
-      return item.date_published
+    def copyright(self):
+        curr_year = datetime.datetime.now().year
+        if curr_year == BASE_YEAR:
+            year_range = str(BASE_YEAR)
+        else:
+            year_range = "%d - %d" % (BASE_YEAR, curr_year)
 
-   def item_categories(self, item):
-      return (item.category.title, )
+        return 'Copyright (C) %s, SurfGuitar101.com' % year_range
+    
+    def items(self):
+        return Story.objects.order_by('-date_published')[:5]
+
+    def item_pubdate(self, item):
+        return item.date_published
+
+    def item_categories(self, item):
+        return (item.category.title, )