# HG changeset patch # User neko259 # Date 2015-10-20 13:10:30 # Node ID 2ac2fd63342ade0e40d40f71e72fbef97b4b7bc4 # Parent 4e03414170d2b68bdbcefa49cdfdc87450f04d9a Made feed view use the new-style paginator links diff --git a/boards/templates/boards/feed.html b/boards/templates/boards/feed.html --- a/boards/templates/boards/feed.html +++ b/boards/templates/boards/feed.html @@ -61,7 +61,7 @@ {% ifequal page current_page.number %} class="current_page" {% endifequal %} - href="{% url "feed" %}?page={{ page }}{{ additional_attrs }}">{{ page }} + href="{% page_url paginator page %}">{{ page }} {% if not forloop.last %},{% endif %} {% endfor %} {% endwith %} diff --git a/boards/views/feed.py b/boards/views/feed.py --- a/boards/views/feed.py +++ b/boards/views/feed.py @@ -47,12 +47,14 @@ class FeedView(PostMixin, BaseBoardView) additional_params['tripcode'] = tripcode params[PARAMETER_ADDITONAL_ATTRS] = '&tripcode=' + tripcode - self.get_page_context(paginator, params, page, additional_params) + paginator.set_url(reverse('feed'), request.GET.dict()) + + self.get_page_context(paginator, params, page) return render(request, TEMPLATE, params) # TODO Dedup this into PagedMixin - def get_page_context(self, paginator, params, page, additional_params): + def get_page_context(self, paginator, params, page): """ Get pagination context variables """ @@ -61,21 +63,9 @@ class FeedView(PostMixin, BaseBoardView) current_page = paginator.page(int(page)) params[PARAMETER_CURRENT_PAGE] = current_page if current_page.has_previous(): - params[PARAMETER_PREV_LINK] = self.get_previous_page_link( - current_page) - for param in additional_params.keys(): - params[PARAMETER_PREV_LINK] += '&{}={}'.format( - param, additional_params[param]) + params[PARAMETER_PREV_LINK] = paginator.get_page_url( + current_page.previous_page_number()) if current_page.has_next(): - params[PARAMETER_NEXT_LINK] = self.get_next_page_link(current_page) - for param in additional_params.keys(): - params[PARAMETER_NEXT_LINK] += '&{}={}'.format( - param, additional_params[param]) + params[PARAMETER_NEXT_LINK] = paginator.get_page_url( + current_page.next_page_number()) - def get_previous_page_link(self, current_page): - return reverse('feed') + '?page={}'.format( - current_page.previous_page_number()) - - def get_next_page_link(self, current_page): - return reverse('feed') + '?page={}'.format( - current_page.next_page_number())