X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/410bfa05ee36ed1d99356c443a5f3f6aa3ee9578..0f7b31c39bb2b3e72e99168172e5192118f43eec:/forum/feed.py diff --git a/forum/feed.py b/forum/feed.py index 4017d61..2575e66 100644 --- a/forum/feed.py +++ b/forum/feed.py @@ -1,28 +1,30 @@ -#!/usr/bin/env python -#encoding:utf-8 -#------------------------------------------------------------------------------- -# Name: Syndication feed class for subsribtion -# Purpose: -# -# Author: Mike -# -# Created: 29/01/2009 -# Copyright: (c) CNPROG.COM 2009 -# Licence: GPL V2 -#------------------------------------------------------------------------------- -from django.contrib.syndication.feeds import Feed, FeedDoesNotExist +try: + from django.contrib.syndication.views import Feed, FeedDoesNotExist +except: + from django.contrib.syndication.feeds import Feed, FeedDoesNotExist + from django.utils.translation import ugettext as _ from models import Question -from django.conf import settings -class RssLastestQuestionsFeed(Feed): - title = str(settings.APP_TITLE) + _(' - ')+ _('latest questions') - link = settings.APP_URL #+ '/' + _('question/') - description = settings.APP_DESCRIPTION - #ttl = 10 +from forum import settings + + +class RssQuestionFeed(Feed): copyright = settings.APP_COPYRIGHT + def __init__(self, question_list, title, description, request): + self._title = title + self._description = description + self._question_list = question_list + self._url = request.path + + def title(self): + return self._title + + def link(self): + return self._url + def item_link(self, item): - return self.link + item.get_absolute_url() + return item.get_absolute_url() def item_author_name(self, item): return item.author.username @@ -34,10 +36,4 @@ class RssLastestQuestionsFeed(Feed): return item.added_at def items(self, item): - return Question.objects.filter(deleted=None).order_by('-last_activity_at')[:30] - -def main(): - pass - -if __name__ == '__main__': - main() + return self._question_list[:30]