From f02e99135ff3f02bbb06344722d5534e41257068 Mon Sep 17 00:00:00 2001 From: Nicolas Joyard <joyard.nicolas@gmail.com> Date: Fri, 17 Jun 2016 08:39:07 +0200 Subject: [PATCH] Fix pagination links not keeping querystring --- core/templates/core/blocks/active-filter.haml | 4 ++-- core/templates/core/blocks/grid-list.haml | 4 ++-- core/templates/core/blocks/pagination.haml | 2 +- core/views.py | 6 ++++++ 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/templates/core/blocks/active-filter.haml b/core/templates/core/blocks/active-filter.haml index 5e51e92d..e60fc269 100644 --- a/core/templates/core/blocks/active-filter.haml +++ b/core/templates/core/blocks/active-filter.haml @@ -1,9 +1,9 @@ Display : - if active_only current legislature only / - %a{'href': '?active_only=0'} + %a{'href': '?={queries.urlencode}&active_only=0'} all data - else - %a{'href': '?active_only=1'} + %a{'href': '?={queries.urlencode}&active_only=1'} current legislature only ="/ all data" \ No newline at end of file diff --git a/core/templates/core/blocks/grid-list.haml b/core/templates/core/blocks/grid-list.haml index 79a21ef8..00606704 100644 --- a/core/templates/core/blocks/grid-list.haml +++ b/core/templates/core/blocks/grid-list.haml @@ -1,5 +1,5 @@ %span.grid-list-selector - %a{:href => '?display=grid'} + %a{:href => '?={queries.urlencode}&display=grid'} <i class="fa fa-th"></i> - %a{:href => '?display=list'} + %a{:href => '?={queries.urlencode}&display=list'} <i class="fa fa-th-list"></i> diff --git a/core/templates/core/blocks/pagination.haml b/core/templates/core/blocks/pagination.haml index fb0ffa6c..d90403d8 100644 --- a/core/templates/core/blocks/pagination.haml +++ b/core/templates/core/blocks/pagination.haml @@ -47,7 +47,7 @@ {{ paginator.per_page }} ( - for limit in pagination_limits - %a{'href': '?paginate_by={{ limit }}'} + %a{'href': '?={queries.urlencode}&paginate_by={{ limit }}'} {{ limit }} - if not forloop.last \/ diff --git a/core/views.py b/core/views.py index 6b72f0bf..5a0a8605 100644 --- a/core/views.py +++ b/core/views.py @@ -1,4 +1,7 @@ # coding: utf-8 + +from copy import copy + from django import http import unicodecsv as csv @@ -77,6 +80,9 @@ class PaginationMixin(object): c['pagination_limits'] = self.pagination_limits c['paginate_by'] = self.request.session['paginate_by'] c['page_range'] = self.get_page_range(c['page_obj']) + c['queries'] = copy(self.request.GET) + if 'page' in c['queries']: + del c['queries']['page'] return c -- GitLab