summaryrefslogtreecommitdiff
path: root/sublab_project/news/feeds.py
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2011-12-30 03:56:53 +0100
committerChristian Franke <nobody@nowhere.ws>2011-12-30 03:57:48 +0100
commit7516ffd1a1598701ec6ba1a2edf9d50836ba51a1 (patch)
tree6cc82bd52c586b25ab7403ccbfb3b6b1d60b8e75 /sublab_project/news/feeds.py
parent8d7103f5d53c31f40bf6725a2923046e664eca57 (diff)
Add newsfeed
Diffstat (limited to 'sublab_project/news/feeds.py')
-rw-r--r--sublab_project/news/feeds.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/sublab_project/news/feeds.py b/sublab_project/news/feeds.py
new file mode 100644
index 0000000..011cee5
--- /dev/null
+++ b/sublab_project/news/feeds.py
@@ -0,0 +1,32 @@
+from django.contrib.syndication.views import Feed
+from django.utils.feedgenerator import Atom1Feed
+from django.core.urlresolvers import reverse
+from django.utils.html import strip_tags
+
+from news.models import News
+
+class NewsFeed(Feed):
+ title = "sublab.org news"
+ description = "the latest news from your sublab"
+
+ def link(self):
+ return reverse(self)
+
+ def items(self):
+ return News.objects.order_by('-date_updated')[:10]
+
+ def item_author_name(self, item):
+ return item.author
+
+ def item_description(self, item):
+ return strip_tags(item.content_html)
+
+ def item_title(self, item):
+ return item.title
+
+ def item_pubdate(self, item):
+ return item.date_created
+
+class NewsFeedAtom(NewsFeed):
+ feed_type = Atom1Feed
+ subtitle = NewsFeed.description