# HG changeset patch # User neko259 # Date 2015-11-14 17:08:21 # Node ID bb2d1922523b69f1e442ccc47a6d2c9db66a0849 # Parent d814364fbb2101bccf4af77055bfcee555bda152 Fixed thread RSS. Limit items count in RSS diff --git a/boards/config/default_settings.ini b/boards/config/default_settings.ini --- a/boards/config/default_settings.ini +++ b/boards/config/default_settings.ini @@ -32,3 +32,6 @@ ArchiveThreads = true [External] # Thread update WebsocketsEnabled = false + +[RSS] +MaxItems = 20 \ No newline at end of file diff --git a/boards/rss.py b/boards/rss.py --- a/boards/rss.py +++ b/boards/rss.py @@ -4,7 +4,10 @@ from django.shortcuts import get_object_ from boards.models import Post, Tag, Thread from boards import settings -__author__ = 'neko259' +__author__ = 'nekorin' + + +MAX_ITEMS = settings.get_int('RSS', 'MaxItems') # TODO Make tests for all of these @@ -15,7 +18,7 @@ class AllThreadsFeed(Feed): description_template = 'boards/rss/post.html' def items(self): - return Thread.objects.filter(archived=False).order_by('-id') + return Thread.objects.filter(archived=False).order_by('-id')[:MAX_ITEMS] def item_title(self, item): return item.get_opening_post().title @@ -33,7 +36,7 @@ class TagThreadsFeed(Feed): description_template = 'boards/rss/post.html' def items(self, obj): - return obj.get_threads().filter(archived=False).order_by('-id') + return obj.get_threads().filter(archived=False).order_by('-id')[:MAX_ITEMS] def get_object(self, request, tag_name): return get_object_or_404(Tag, name=tag_name) @@ -57,7 +60,7 @@ class ThreadPostsFeed(Feed): description_template = 'boards/rss/post.html' def items(self, obj): - return obj.get_thread().get_replies() + return obj.get_thread().get_replies().order_by('-pub_time')[:MAX_ITEMS] def get_object(self, request, post_id): return get_object_or_404(Post, id=post_id) diff --git a/boards/views/thread/thread.py b/boards/views/thread/thread.py --- a/boards/views/thread/thread.py +++ b/boards/views/thread/thread.py @@ -176,4 +176,4 @@ class ThreadView(BaseBoardView, PostMixi post.save(update_fields=['hidden']) def get_rss_url(self, opening_id): - return reverse('thread', kwargs={'post_id': opening_id}) \ No newline at end of file + return reverse('thread', kwargs={'post_id': opening_id}) + 'rss/'