gremmie@1: """ gremmie@1: This file contains the feed classes for the news application. gremmie@1: """ bgneal@170: import datetime gremmie@1: gremmie@1: from django.contrib.syndication.feeds import Feed bgneal@170: gremmie@1: from news.models import Story gremmie@1: bgneal@170: BASE_YEAR = 2010 bgneal@170: gremmie@1: gremmie@1: class LatestNewsFeed(Feed): bgneal@170: """The Feed class for the news application""" gremmie@1: bgneal@170: title = 'SurfGuitar101.com News Feed' bgneal@170: link = '/feeds/news/' bgneal@170: description = 'News articles and stories from SurfGuitar101.com' bgneal@170: ttl = '720' gremmie@1: bgneal@170: title_template = 'news/feed_title.html' bgneal@170: description_template = 'news/feed_description.html' gremmie@1: bgneal@170: def copyright(self): bgneal@170: curr_year = datetime.datetime.now().year bgneal@170: if curr_year == BASE_YEAR: bgneal@170: year_range = str(BASE_YEAR) bgneal@170: else: bgneal@170: year_range = "%d - %d" % (BASE_YEAR, curr_year) gremmie@1: bgneal@170: return 'Copyright (C) %s, SurfGuitar101.com' % year_range bgneal@170: bgneal@170: def items(self): bgneal@170: return Story.objects.order_by('-date_published')[:5] bgneal@170: bgneal@170: def item_pubdate(self, item): bgneal@170: return item.date_published bgneal@170: bgneal@170: def item_categories(self, item): bgneal@170: return (item.category.title, )