##// END OF EJS Templates
Fixed tag RSS
neko259 -
r1392:00e38830 default
parent child Browse files
Show More
@@ -1,80 +1,80 b''
1 1 from django.contrib.syndication.views import Feed
2 2 from django.core.urlresolvers import reverse
3 3 from django.shortcuts import get_object_or_404
4 4 from boards.models import Post, Tag, Thread
5 5 from boards import settings
6 6
7 7 __author__ = 'neko259'
8 8
9 9
10 10 # TODO Make tests for all of these
11 11 class AllThreadsFeed(Feed):
12 12
13 13 title = settings.get('Version', 'SiteName') + ' - All threads'
14 14 link = '/'
15 15 description_template = 'boards/rss/post.html'
16 16
17 17 def items(self):
18 18 return Thread.objects.filter(archived=False).order_by('-id')
19 19
20 20 def item_title(self, item):
21 21 return item.get_opening_post().title
22 22
23 23 def item_link(self, item):
24 24 return reverse('thread', args={item.get_opening_post_id()})
25 25
26 26 def item_pubdate(self, item):
27 27 return item.get_pub_time()
28 28
29 29
30 30 class TagThreadsFeed(Feed):
31 31
32 32 link = '/'
33 33 description_template = 'boards/rss/post.html'
34 34
35 35 def items(self, obj):
36 return obj.threads.filter(archived=False).order_by('-id')
36 return obj.get_threads().filter(archived=False).order_by('-id')
37 37
38 38 def get_object(self, request, tag_name):
39 39 return get_object_or_404(Tag, name=tag_name)
40 40
41 41 def item_title(self, item):
42 42 return item.get_opening_post().title
43 43
44 44 def item_link(self, item):
45 45 return reverse('thread', args={item.get_opening_post_id()})
46 46
47 47 def item_pubdate(self, item):
48 48 return item.get_pub_time()
49 49
50 50 def title(self, obj):
51 51 return obj.name
52 52
53 53
54 54 class ThreadPostsFeed(Feed):
55 55
56 56 link = '/'
57 57 description_template = 'boards/rss/post.html'
58 58
59 59 def items(self, obj):
60 60 return obj.get_thread().get_replies()
61 61
62 62 def get_object(self, request, post_id):
63 63 return get_object_or_404(Post, id=post_id)
64 64
65 65 def item_title(self, item):
66 66 return item.title
67 67
68 68 def item_link(self, item):
69 69 if not item.is_opening():
70 70 return reverse('thread', args={
71 71 item.get_thread().get_opening_post_id()
72 72 }) + "#" + str(item.id)
73 73 else:
74 74 return reverse('thread', args={item.id})
75 75
76 76 def item_pubdate(self, item):
77 77 return item.pub_time
78 78
79 79 def title(self, obj):
80 80 return obj.title
General Comments 0
You need to be logged in to leave comments. Login now