Mercurial > public > sg101
diff 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 |
line wrap: on
line diff
--- a/gpp/news/feeds.py Wed Mar 03 04:09:42 2010 +0000 +++ b/gpp/news/feeds.py Thu Mar 11 02:34:07 2010 +0000 @@ -1,13 +1,13 @@ """ This file contains the feed classes for the news application. """ -import datetime - -from django.contrib.syndication.feeds import Feed +from django.contrib.syndication.views import Feed +from django.utils.decorators import method_decorator +from django.views.decorators.cache import cache_page from news.models import Story - -BASE_YEAR = 2010 +from core.functions import get_full_name +from core.functions import copyright_str class LatestNewsFeed(Feed): @@ -17,22 +17,28 @@ link = '/feeds/news/' description = 'News articles and stories from SurfGuitar101.com' ttl = '720' + author_name = 'Brian Neal' + author_email = 'admin@surfguitar101.com' - title_template = 'news/feed_title.html' - description_template = 'news/feed_description.html' + @method_decorator(cache_page(4 * 60 * 60)) + def __call__(self, request, *args, **kwargs): + return super(LatestNewsFeed, self).__call__(request, *args, **kwargs) - 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) - - return 'Copyright (C) %s, SurfGuitar101.com' % year_range + def feed_copyright(self): + return copyright_str() def items(self): return Story.objects.order_by('-date_published')[:5] + def item_title(self, item): + return item.title + + def item_description(self, item): + return item.short_text + item.long_text + + def item_author_name(self, item): + return get_full_name(item.submitter) + def item_pubdate(self, item): return item.date_published