blob: 779049c7ced2692751f835852d9075823335a6a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
"""
#-------------------------------------------------------------------------------
# Name: Syndication feed class for subscription
# Purpose:
#
# Author: Mike
#
# Created: 29/01/2009
# Copyright: (c) CNPROG.COM 2009
# Licence: GPL V2
#-------------------------------------------------------------------------------
"""
#!/usr/bin/env python
#encoding:utf-8
from django.contrib.syndication.feeds import Feed, FeedDoesNotExist
from django.utils.translation import ugettext as _
from forum.models import Question
from forum.conf import settings as forum_settings
class RssLastestQuestionsFeed(Feed):
"""rss feed class for the latest questions
"""
title = forum_settings.APP_TITLE + _(' - ')+ _('latest questions')
link = forum_settings.APP_URL
description = forum_settings.APP_DESCRIPTION
#ttl = 10
copyright = forum_settings.APP_COPYRIGHT
def item_link(self, item):
"""get full url to the item
"""
return self.link + item.get_absolute_url()
def item_author_name(self, item):
"""get name of author
"""
return item.author.username
def item_author_link(self, item):
"""get url of the author's profile
"""
return item.author.get_profile_url()
def item_pubdate(self, item):
"""get date of creation for the item
"""
return item.added_at
def items(self, item):
"""get questions for the feed
"""
return Question.objects.filter(
deleted=False
).order_by(
'-last_activity_at'
)[:30]
def main():
"""main function for use as a script
"""
pass
if __name__ == '__main__':
main()
|