diff --git a/boards/views/all_threads.py b/boards/views/all_threads.py --- a/boards/views/all_threads.py +++ b/boards/views/all_threads.py @@ -52,7 +52,7 @@ class AllThreadsView(PostMixin, BaseBoar form = ThreadForm(error_class=PlainErrorList) self.settings_manager = get_settings_manager(request) - paginator = get_paginator(self.get_threads(), + paginator = get_paginator(self.get_threads().order_by('-bump_time'), settings.get_int('View', 'ThreadsPerPage')) paginator.current_page = int(page) @@ -97,13 +97,16 @@ class AllThreadsView(PostMixin, BaseBoar params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page) def get_previous_page_link(self, current_page): - return reverse('index') + '?page=' \ + return self.get_reverse_url() + '?page=' \ + str(current_page.previous_page_number()) def get_next_page_link(self, current_page): - return reverse('index') + '?page=' \ + return self.get_reverse_url() + '?page=' \ + str(current_page.next_page_number()) + def get_reverse_url(self): + return reverse('index') + @transaction.atomic def create_thread(self, request, form: ThreadForm, html_response=True): """ @@ -146,5 +149,5 @@ class AllThreadsView(PostMixin, BaseBoar Gets list of threads that will be shown on a page. """ - return Thread.objects.order_by('-bump_time')\ + return Thread.objects\ .exclude(tags__in=self.settings_manager.get_hidden_tags()) diff --git a/boards/views/tag_threads.py b/boards/views/tag_threads.py --- a/boards/views/tag_threads.py +++ b/boards/views/tag_threads.py @@ -55,15 +55,9 @@ class TagView(AllThreadsView, Dispatcher return params - def get_previous_page_link(self, current_page): + def get_reverse_url(self): return reverse('tag', kwargs={ - 'tag_name': self.tag_name, - }) + '?page=' + str(current_page.previous_page_number()) - - def get_next_page_link(self, current_page): - return reverse('tag', kwargs={ - 'tag_name': self.tag_name, - }) + '?page=' + str(current_page.next_page_number()) + 'tag_name': self.tag_name}) def get(self, request, tag_name, form=None): self.tag_name = tag_name