comparison 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
comparison
equal deleted inserted replaced
169:7071b196ddd5 170:6f14970b103a
1 """ 1 """
2 This file contains the feed classes for the news application. 2 This file contains the feed classes for the news application.
3 """ 3 """
4 import datetime
4 5
5 from django.contrib.syndication.feeds import Feed 6 from django.contrib.syndication.feeds import Feed
7
6 from news.models import Story 8 from news.models import Story
9
10 BASE_YEAR = 2010
7 11
8 12
9 class LatestNewsFeed(Feed): 13 class LatestNewsFeed(Feed):
10 """The Feed class for the news application""" 14 """The Feed class for the news application"""
11 15
12 title = 'SurfGuitar101.com News Feed' 16 title = 'SurfGuitar101.com News Feed'
13 link = '/feeds/news/' 17 link = '/feeds/news/'
14 description = 'News articles and stories from SurfGuitar101.com' 18 description = 'News articles and stories from SurfGuitar101.com'
15 copyright = 'Copyright (C) 2008, Brian Neal' 19 ttl = '720'
16 ttl = '720'
17 20
18 title_template = 'news/feed_title.html' 21 title_template = 'news/feed_title.html'
19 description_template = 'news/feed_description.html' 22 description_template = 'news/feed_description.html'
20
21 def items(self):
22 return Story.objects.order_by('-date_published')[:5]
23 23
24 def item_pubdate(self, item): 24 def copyright(self):
25 return item.date_published 25 curr_year = datetime.datetime.now().year
26 if curr_year == BASE_YEAR:
27 year_range = str(BASE_YEAR)
28 else:
29 year_range = "%d - %d" % (BASE_YEAR, curr_year)
26 30
27 def item_categories(self, item): 31 return 'Copyright (C) %s, SurfGuitar101.com' % year_range
28 return (item.category.title, ) 32
33 def items(self):
34 return Story.objects.order_by('-date_published')[:5]
35
36 def item_pubdate(self, item):
37 return item.date_published
38
39 def item_categories(self, item):
40 return (item.category.title, )