##// END OF EJS Templates
Small refactoring of threads view
neko259 -
r1374:e531c1da default
parent child Browse files
Show More
@@ -52,7 +52,7 b' class AllThreadsView(PostMixin, BaseBoar'
52 52 form = ThreadForm(error_class=PlainErrorList)
53 53
54 54 self.settings_manager = get_settings_manager(request)
55 paginator = get_paginator(self.get_threads(),
55 paginator = get_paginator(self.get_threads().order_by('-bump_time'),
56 56 settings.get_int('View', 'ThreadsPerPage'))
57 57 paginator.current_page = int(page)
58 58
@@ -97,13 +97,16 b' class AllThreadsView(PostMixin, BaseBoar'
97 97 params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page)
98 98
99 99 def get_previous_page_link(self, current_page):
100 return reverse('index') + '?page=' \
100 return self.get_reverse_url() + '?page=' \
101 101 + str(current_page.previous_page_number())
102 102
103 103 def get_next_page_link(self, current_page):
104 return reverse('index') + '?page=' \
104 return self.get_reverse_url() + '?page=' \
105 105 + str(current_page.next_page_number())
106 106
107 def get_reverse_url(self):
108 return reverse('index')
109
107 110 @transaction.atomic
108 111 def create_thread(self, request, form: ThreadForm, html_response=True):
109 112 """
@@ -146,5 +149,5 b' class AllThreadsView(PostMixin, BaseBoar'
146 149 Gets list of threads that will be shown on a page.
147 150 """
148 151
149 return Thread.objects.order_by('-bump_time')\
152 return Thread.objects\
150 153 .exclude(tags__in=self.settings_manager.get_hidden_tags())
@@ -55,15 +55,9 b' class TagView(AllThreadsView, Dispatcher'
55 55
56 56 return params
57 57
58 def get_previous_page_link(self, current_page):
58 def get_reverse_url(self):
59 59 return reverse('tag', kwargs={
60 'tag_name': self.tag_name,
61 }) + '?page=' + str(current_page.previous_page_number())
62
63 def get_next_page_link(self, current_page):
64 return reverse('tag', kwargs={
65 'tag_name': self.tag_name,
66 }) + '?page=' + str(current_page.next_page_number())
60 'tag_name': self.tag_name})
67 61
68 62 def get(self, request, tag_name, form=None):
69 63 self.tag_name = tag_name
General Comments 0
You need to be logged in to leave comments. Login now