annotate 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
rev   line source
gremmie@1 1 """
gremmie@1 2 This file contains the feed classes for the news application.
gremmie@1 3 """
bgneal@176 4 from django.contrib.syndication.views import Feed
bgneal@176 5 from django.utils.decorators import method_decorator
bgneal@176 6 from django.views.decorators.cache import cache_page
bgneal@170 7
gremmie@1 8 from news.models import Story
bgneal@176 9 from core.functions import get_full_name
bgneal@176 10 from core.functions import copyright_str
bgneal@170 11
gremmie@1 12
gremmie@1 13 class LatestNewsFeed(Feed):
bgneal@170 14 """The Feed class for the news application"""
gremmie@1 15
bgneal@170 16 title = 'SurfGuitar101.com News Feed'
bgneal@170 17 link = '/feeds/news/'
bgneal@170 18 description = 'News articles and stories from SurfGuitar101.com'
bgneal@170 19 ttl = '720'
bgneal@176 20 author_name = 'Brian Neal'
bgneal@176 21 author_email = 'admin@surfguitar101.com'
gremmie@1 22
bgneal@176 23 @method_decorator(cache_page(4 * 60 * 60))
bgneal@176 24 def __call__(self, request, *args, **kwargs):
bgneal@176 25 return super(LatestNewsFeed, self).__call__(request, *args, **kwargs)
gremmie@1 26
bgneal@176 27 def feed_copyright(self):
bgneal@176 28 return copyright_str()
bgneal@170 29
bgneal@170 30 def items(self):
bgneal@170 31 return Story.objects.order_by('-date_published')[:5]
bgneal@170 32
bgneal@176 33 def item_title(self, item):
bgneal@176 34 return item.title
bgneal@176 35
bgneal@176 36 def item_description(self, item):
bgneal@176 37 return item.short_text + item.long_text
bgneal@176 38
bgneal@176 39 def item_author_name(self, item):
bgneal@176 40 return get_full_name(item.submitter)
bgneal@176 41
bgneal@170 42 def item_pubdate(self, item):
bgneal@170 43 return item.date_published
bgneal@170 44
bgneal@170 45 def item_categories(self, item):
bgneal@170 46 return (item.category.title, )