From 7751c8c26305786b4e2315e9b93695d3e15c6357 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Thu, 3 May 2018 14:40:15 +0200 Subject: [PATCH] Workaound pour les vues necessitant un paginateur --- cotisations/views.py | 2 +- logs/views.py | 2 +- re2o/utils.py | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cotisations/views.py b/cotisations/views.py index 78ee0d74..e5e521fa 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -643,7 +643,7 @@ def control(request): fields=('control', 'valid'), extra=0 ) - invoice_list = re2o_paginator(request, invoice_list, pagination_number) + invoice_list = re2o_paginator(request, invoice_list, pagination_number, force_paginate=True) control_invoices_form = control_invoices_formset( request.POST or None, queryset=invoice_list.object_list diff --git a/logs/views.py b/logs/views.py index afb0a118..41f1af6e 100644 --- a/logs/views.py +++ b/logs/views.py @@ -128,7 +128,7 @@ def index(request): request.GET.get('order'), SortTable.LOGS_INDEX ) - versions = re2o_paginator(request, versions, pagination_number) + versions = re2o_paginator(request, versions, pagination_number, force_paginate=True) # Force to have a list instead of QuerySet versions.count(0) # Items to remove later because invalid diff --git a/re2o/utils.py b/re2o/utils.py index 639d6a07..8d53638d 100644 --- a/re2o/utils.py +++ b/re2o/utils.py @@ -292,12 +292,12 @@ class SortTable: return request -def re2o_paginator(request, query_set, pagination_number): +def re2o_paginator(request, query_set, pagination_number, force_paginate=False): """Paginator script for list display in re2o. :request: :query_set: Query_set to paginate :pagination_number: Number of entries to display""" - if query_set.count() > pagination_number: + if force_paginate or query_set.count() > pagination_number: paginator = Paginator(query_set, pagination_number) page = request.GET.get('page') try: