Mercurial > public > sg101
annotate gpp/news/feeds.py @ 175:776028f4bced
Ticket #60. The TEMPLATE_CONTEXT_PROCESSOR django.core.context_processors.auth moved to django.contrib.auth.context_processors.auth.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 03 Mar 2010 04:09:42 +0000 |
parents | 6f14970b103a |
children | b7ac381996e8 |
rev | line source |
---|---|
gremmie@1 | 1 """ |
gremmie@1 | 2 This file contains the feed classes for the news application. |
gremmie@1 | 3 """ |
bgneal@170 | 4 import datetime |
gremmie@1 | 5 |
gremmie@1 | 6 from django.contrib.syndication.feeds import Feed |
bgneal@170 | 7 |
gremmie@1 | 8 from news.models import Story |
gremmie@1 | 9 |
bgneal@170 | 10 BASE_YEAR = 2010 |
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' |
gremmie@1 | 20 |
bgneal@170 | 21 title_template = 'news/feed_title.html' |
bgneal@170 | 22 description_template = 'news/feed_description.html' |
gremmie@1 | 23 |
bgneal@170 | 24 def copyright(self): |
bgneal@170 | 25 curr_year = datetime.datetime.now().year |
bgneal@170 | 26 if curr_year == BASE_YEAR: |
bgneal@170 | 27 year_range = str(BASE_YEAR) |
bgneal@170 | 28 else: |
bgneal@170 | 29 year_range = "%d - %d" % (BASE_YEAR, curr_year) |
gremmie@1 | 30 |
bgneal@170 | 31 return 'Copyright (C) %s, SurfGuitar101.com' % year_range |
bgneal@170 | 32 |
bgneal@170 | 33 def items(self): |
bgneal@170 | 34 return Story.objects.order_by('-date_published')[:5] |
bgneal@170 | 35 |
bgneal@170 | 36 def item_pubdate(self, item): |
bgneal@170 | 37 return item.date_published |
bgneal@170 | 38 |
bgneal@170 | 39 def item_categories(self, item): |
bgneal@170 | 40 return (item.category.title, ) |