Show More
@@ -65,7 +65,7 b' class AllThreadsView(PostMixin, BaseBoar' | |||||
65 | params[CONTEXT_FORM] = form |
|
65 | params[CONTEXT_FORM] = form | |
66 | params[PARAMETER_BANNERS] = Banner.objects.order_by('-id').all() |
|
66 | params[PARAMETER_BANNERS] = Banner.objects.order_by('-id').all() | |
67 |
|
67 | |||
68 | self.get_page_context(paginator, params, page) |
|
68 | self.get_page_context(paginator, params, page, request.GET.dict()) | |
69 |
|
69 | |||
70 | return render(request, TEMPLATE, params) |
|
70 | return render(request, TEMPLATE, params) | |
71 |
|
71 | |||
@@ -82,7 +82,7 b' class AllThreadsView(PostMixin, BaseBoar' | |||||
82 |
|
82 | |||
83 | return self.get(request, form) |
|
83 | return self.get(request, form) | |
84 |
|
84 | |||
85 | def get_page_context(self, paginator, params, page): |
|
85 | def get_page_context(self, paginator, params, page, url_params): | |
86 | """ |
|
86 | """ | |
87 | Get pagination context variables |
|
87 | Get pagination context variables | |
88 | """ |
|
88 | """ | |
@@ -92,20 +92,24 b' class AllThreadsView(PostMixin, BaseBoar' | |||||
92 | params[PARAMETER_CURRENT_PAGE] = current_page |
|
92 | params[PARAMETER_CURRENT_PAGE] = current_page | |
93 | if current_page.has_previous(): |
|
93 | if current_page.has_previous(): | |
94 | params[PARAMETER_PREV_LINK] = self.get_previous_page_link( |
|
94 | params[PARAMETER_PREV_LINK] = self.get_previous_page_link( | |
95 | current_page) |
|
95 | current_page, url_params) | |
96 | if current_page.has_next(): |
|
96 | if current_page.has_next(): | |
97 |
params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page |
|
97 | params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page, | |
|
98 | url_params) | |||
|
99 | ||||
|
100 | def get_previous_page_link(self, current_page, params): | |||
|
101 | params['page'] = current_page.previous_page_number() | |||
|
102 | return self.get_reverse_url(params) | |||
98 |
|
103 | |||
99 |
def get_ |
|
104 | def get_next_page_link(self, current_page, params): | |
100 | return self.get_reverse_url() + '?page=' \ |
|
105 | params['page'] = current_page.next_page_number() | |
101 | + str(current_page.previous_page_number()) |
|
106 | return self.get_reverse_url(params) | |
102 |
|
107 | |||
103 |
def get_ |
|
108 | def get_url_params(self, params): | |
104 | return self.get_reverse_url() + '?page=' \ |
|
109 | return '?' + '&'.join(['{}={}'.format(key, params[key]) for key in params.keys()]) | |
105 | + str(current_page.next_page_number()) |
|
|||
106 |
|
110 | |||
107 | def get_reverse_url(self): |
|
111 | def get_reverse_url(self, params): | |
108 | return reverse('index') |
|
112 | return reverse('index') + self.get_url_params(params) | |
109 |
|
113 | |||
110 | @transaction.atomic |
|
114 | @transaction.atomic | |
111 | def create_thread(self, request, form: ThreadForm, html_response=True): |
|
115 | def create_thread(self, request, form: ThreadForm, html_response=True): |
@@ -55,9 +55,8 b' class TagView(AllThreadsView, Dispatcher' | |||||
55 |
|
55 | |||
56 | return params |
|
56 | return params | |
57 |
|
57 | |||
58 | def get_reverse_url(self): |
|
58 | def get_reverse_url(self, params): | |
59 | return reverse('tag', kwargs={ |
|
59 | return reverse('tag', kwargs={'tag_name': self.tag_name}) + self.get_url_params(params) | |
60 | 'tag_name': self.tag_name}) |
|
|||
61 |
|
60 | |||
62 | def get(self, request, tag_name, form=None): |
|
61 | def get(self, request, tag_name, form=None): | |
63 | self.tag_name = tag_name |
|
62 | self.tag_name = tag_name |
General Comments 0
You need to be logged in to leave comments.
Login now