summaryrefslogtreecommitdiff
path: root/feeds.py
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-06-08 10:52:53 -0500
committerDan McGee <dan@archlinux.org>2010-06-08 10:52:53 -0500
commit89cae2bcb5610fa50d70e47bf74853bb04dbca9c (patch)
tree3dd2c25f7fc8365230870310fbd381646f5efbd6 /feeds.py
parent8bf0bfeac7f1cdfee19432b3eb77c48f4fedef08 (diff)
Update feeds to new 1.2 framework
Feeds are now views-based and don't need the dictionary anymore. get_object() now takes named arguments as well making it a bit more understandable when reading the code. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'feeds.py')
-rw-r--r--feeds.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/feeds.py b/feeds.py
index 32190a7b..0bb0e352 100644
--- a/feeds.py
+++ b/feeds.py
@@ -1,28 +1,27 @@
import datetime
-from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
+from django.contrib.syndication.feeds import FeedDoesNotExist
+from django.contrib.syndication.views import Feed
from django.db.models import Q
from main.models import Arch, Repo, Package, News
class PackageFeed(Feed):
link = '/packages/'
+ title_template = 'feeds/packages_title.html'
+ description_template = 'feeds/packages_description.html'
- def get_object(self, bits):
- # just cut the BS early
- if len(bits) > 2:
- raise FeedDoesNotExist
-
+ def get_object(self, request, arch='', repo=''):
obj = dict()
qs = Package.objects.select_related('arch', 'repo').order_by('-last_update')
- if len(bits) > 0:
+ if arch != '':
# feed for a single arch, also include 'any' packages everywhere
- a = Arch.objects.get(name=bits[0])
+ a = Arch.objects.get(name=arch)
qs = qs.filter(Q(arch=a) | Q(arch__name__iexact='any'))
obj['arch'] = a
- if len(bits) > 1:
+ if repo != '':
# feed for a single arch AND repo
- r = Repo.objects.get(name=bits[1])
+ r = Repo.objects.get(name=repo)
qs = qs.filter(repo=r)
obj['repo'] = r
obj['qs'] = qs[:50]
@@ -61,6 +60,8 @@ class NewsFeed(Feed):
title = 'Arch Linux: Recent news updates'
link = '/news/'
description = 'The latest and greatest news from the Arch Linux distribution.'
+ title_template = 'feeds/news_title.html'
+ description_template = 'feeds/news_description.html'
def items(self):
return News.objects.select_related('author').order_by('-postdate', '-id')[:10]
@@ -73,4 +74,3 @@ class NewsFeed(Feed):
return item.author.get_full_name()
# vim: set ts=4 sw=4 et:
-