8242cfea56a3b2dd2adb47e997492f59ccb3dc0e
[sommitrealweird.git] / sommitrealweird / blog / feeds.py
1 from django.contrib.syndication.feeds import Feed
2 from django.utils.feedgenerator import Atom1Feed
3 from blog.models import BlogEntry
4 from django.conf import settings
5
6 class LatestBlogEntriesRss(Feed):
7     title = settings.BLOG_TITLE
8     description = u'Updates on %s' %(title,)
9     link = settings.BLOG_ROOT
10
11     title_template = 'blog/feeds/title.html'
12     description_template = 'blog/feeds/description.html'
13
14     def items(self):
15         try:
16             return BlogEntry.objects.all().order_by('-publish_date')[:20]
17         except:
18             return BlogEntry.objects.all().order_by('-publish_date')
19
20     def author_name(self, obj):
21         return "Brett Parker"
22
23     def author_email(self, obj):
24         return "iDunno@sommitrealweird.co.uk"
25
26     def item_pubdate(self, obj):
27         return obj.publish_date
28
29 class LatestBlogEntries(LatestBlogEntriesRss):
30     feed_type = Atom1Feed
31     subtitle = LatestBlogEntriesRss.description