##// END OF EJS Templates
Fixed thread RSS. Limit items count in RSS
neko259 -
r1400:bb2d1922 default
parent child Browse files
Show More
@@ -32,3 +32,6 b' ArchiveThreads = true'
32 [External]
32 [External]
33 # Thread update
33 # Thread update
34 WebsocketsEnabled = false
34 WebsocketsEnabled = false
35
36 [RSS]
37 MaxItems = 20 No newline at end of file
@@ -4,7 +4,10 b' from django.shortcuts import get_object_'
4 from boards.models import Post, Tag, Thread
4 from boards.models import Post, Tag, Thread
5 from boards import settings
5 from boards import settings
6
6
7 __author__ = 'neko259'
7 __author__ = 'nekorin'
8
9
10 MAX_ITEMS = settings.get_int('RSS', 'MaxItems')
8
11
9
12
10 # TODO Make tests for all of these
13 # TODO Make tests for all of these
@@ -15,7 +18,7 b' class AllThreadsFeed(Feed):'
15 description_template = 'boards/rss/post.html'
18 description_template = 'boards/rss/post.html'
16
19
17 def items(self):
20 def items(self):
18 return Thread.objects.filter(archived=False).order_by('-id')
21 return Thread.objects.filter(archived=False).order_by('-id')[:MAX_ITEMS]
19
22
20 def item_title(self, item):
23 def item_title(self, item):
21 return item.get_opening_post().title
24 return item.get_opening_post().title
@@ -33,7 +36,7 b' class TagThreadsFeed(Feed):'
33 description_template = 'boards/rss/post.html'
36 description_template = 'boards/rss/post.html'
34
37
35 def items(self, obj):
38 def items(self, obj):
36 return obj.get_threads().filter(archived=False).order_by('-id')
39 return obj.get_threads().filter(archived=False).order_by('-id')[:MAX_ITEMS]
37
40
38 def get_object(self, request, tag_name):
41 def get_object(self, request, tag_name):
39 return get_object_or_404(Tag, name=tag_name)
42 return get_object_or_404(Tag, name=tag_name)
@@ -57,7 +60,7 b' class ThreadPostsFeed(Feed):'
57 description_template = 'boards/rss/post.html'
60 description_template = 'boards/rss/post.html'
58
61
59 def items(self, obj):
62 def items(self, obj):
60 return obj.get_thread().get_replies()
63 return obj.get_thread().get_replies().order_by('-pub_time')[:MAX_ITEMS]
61
64
62 def get_object(self, request, post_id):
65 def get_object(self, request, post_id):
63 return get_object_or_404(Post, id=post_id)
66 return get_object_or_404(Post, id=post_id)
@@ -176,4 +176,4 b' class ThreadView(BaseBoardView, PostMixi'
176 post.save(update_fields=['hidden'])
176 post.save(update_fields=['hidden'])
177
177
178 def get_rss_url(self, opening_id):
178 def get_rss_url(self, opening_id):
179 return reverse('thread', kwargs={'post_id': opening_id}) No newline at end of file
179 return reverse('thread', kwargs={'post_id': opening_id}) + 'rss/'
General Comments 0
You need to be logged in to leave comments. Login now