comparison gpp/news/feeds.py @ 176:b7ac381996e8

Implement ticket #59; update RSS feeds for Django 1.2.
author Brian Neal <bgneal@gmail.com>
date Thu, 11 Mar 2010 02:34:07 +0000
parents 6f14970b103a
children 9b63ad1f2ad2
comparison
equal deleted inserted replaced
175:776028f4bced 176:b7ac381996e8
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 from django.contrib.syndication.views import Feed
5 5 from django.utils.decorators import method_decorator
6 from django.contrib.syndication.feeds import Feed 6 from django.views.decorators.cache import cache_page
7 7
8 from news.models import Story 8 from news.models import Story
9 9 from core.functions import get_full_name
10 BASE_YEAR = 2010 10 from core.functions import copyright_str
11 11
12 12
13 class LatestNewsFeed(Feed): 13 class LatestNewsFeed(Feed):
14 """The Feed class for the news application""" 14 """The Feed class for the news application"""
15 15
16 title = 'SurfGuitar101.com News Feed' 16 title = 'SurfGuitar101.com News Feed'
17 link = '/feeds/news/' 17 link = '/feeds/news/'
18 description = 'News articles and stories from SurfGuitar101.com' 18 description = 'News articles and stories from SurfGuitar101.com'
19 ttl = '720' 19 ttl = '720'
20 author_name = 'Brian Neal'
21 author_email = 'admin@surfguitar101.com'
20 22
21 title_template = 'news/feed_title.html' 23 @method_decorator(cache_page(4 * 60 * 60))
22 description_template = 'news/feed_description.html' 24 def __call__(self, request, *args, **kwargs):
25 return super(LatestNewsFeed, self).__call__(request, *args, **kwargs)
23 26
24 def copyright(self): 27 def feed_copyright(self):
25 curr_year = datetime.datetime.now().year 28 return copyright_str()
26 if curr_year == BASE_YEAR:
27 year_range = str(BASE_YEAR)
28 else:
29 year_range = "%d - %d" % (BASE_YEAR, curr_year)
30
31 return 'Copyright (C) %s, SurfGuitar101.com' % year_range
32 29
33 def items(self): 30 def items(self):
34 return Story.objects.order_by('-date_published')[:5] 31 return Story.objects.order_by('-date_published')[:5]
32
33 def item_title(self, item):
34 return item.title
35
36 def item_description(self, item):
37 return item.short_text + item.long_text
38
39 def item_author_name(self, item):
40 return get_full_name(item.submitter)
35 41
36 def item_pubdate(self, item): 42 def item_pubdate(self, item):
37 return item.date_published 43 return item.date_published
38 44
39 def item_categories(self, item): 45 def item_categories(self, item):