~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to pybb/feeds.py

  • Committer: Timo Wingender
  • Date: 2010-06-10 12:42:55 UTC
  • mto: This revision was merged to the branch mainline in revision 218.
  • Revision ID: timo.wingender@gmx.de-20100610124255-4958hbhzx9aqcrpa
Implement password change

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
from django.contrib.syndication.feeds import Feed
 
2
from django.utils.feedgenerator import Atom1Feed
2
3
from django.core.urlresolvers import reverse
3
4
from django.utils.translation import ugettext_lazy as _
4
5
from django.core.exceptions import ObjectDoesNotExist
5
 
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
6
6
 
7
7
from pybb.models import Post, Topic, Forum
8
8
 
27
27
        else: 
28
28
            return self.items_for_object(obj)
29
29
 
30
 
    def link(self, obj):
 
30
    def link(self,obj):
31
31
        if obj == self.all_objects:
32
32
            return reverse('pybb_index')
33
 
        return "/ewfwevw%s" % reverse('pybb_forum', args=(obj.pk,))
 
33
        return reverse('pybb_forum', args=(obj.pk,))
34
34
   
35
35
    def get_object(self,bits):
36
36
        """
46
46
    ##########################
47
47
    # Individual items below #
48
48
    ##########################
49
 
    def item_id(self, obj):
 
49
    def item_guid(self, obj):
50
50
        return str(obj.id)
51
51
 
52
52
    def item_pubdate(self, obj):
53
53
        return obj.created
54
 
 
55
 
    def item_links(self, item):
56
 
        return [{'href': item.get_absolute_url()}, ]
57
 
 
 
54
    
58
55
 
59
56
class LastPosts(PybbFeed):
60
57
    all_title = _('Latest posts on all forums')
69
66
    def items_for_object(self,obj):
70
67
        return Post.objects.filter( topic__forum = obj ).order_by('-created')[:15]
71
68
 
72
 
    def item_author_name(self, item):
73
 
        """
74
 
        Takes the object returned by get_object and returns the feeds's
75
 
        auhor's name as a Python string
76
 
        """
77
 
        return item.user.username
78
 
 
79
69
 
80
70
class LastTopics(PybbFeed):
81
71
    all_title = _('Latest topics on all forums')
90
80
    def items_for_object(self,obj):
91
81
        return Topic.objects.filter( forum = obj ).order_by('-created')[:15]
92
82
 
93
 
    def item_author_name(self, item):
94
 
        """
95
 
        Takes the object returned by get_object and returns the feeds's
96
 
        auhor's name as a Python string
97
 
        """
98
 
        return item.user.username
99