2 from django.contrib.syndication.views import Feed, FeedDoesNotExist
5 from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
8 from django.http import HttpResponse
9 from django.utils.translation import ugettext as _
10 from models import Question
11 from forum import settings
14 class RssQuestionFeed(Feed):
15 copyright = settings.APP_COPYRIGHT
17 def __init__(self, question_list, title, description, request):
19 self._description = description
20 self._question_list = question_list
21 self._url = request.path + "&" + "&".join(["%s=%s" % (k, v) for k, v in request.GET.items() if not k in ('page', 'pagesize', 'sort')])
24 super(RssQuestionFeed, self).__init__('', request)
32 def item_link(self, item):
33 return item.get_absolute_url()
35 def item_author_name(self, item):
36 return item.author.username
38 def item_author_link(self, item):
39 return item.author.get_profile_url()
41 def item_pubdate(self, item):
44 def item_categories(self, item):
45 return item.tagname_list()
47 def items(self, item):
48 return self._question_list[:30]
51 def __call__(self, request):
52 feedgen = self.get_feed('')
53 response = HttpResponse(mimetype=feedgen.mime_type)
54 feedgen.write(response, 'utf-8')