From e4deacbe562776c09b6b62257ff224a85b06efce Mon Sep 17 00:00:00 2001 From: klmp200 Date: Mon, 13 Mar 2017 16:32:59 +0100 Subject: [PATCH] Pagination for cash sumary --- .../templates/counter/cash_summary_list.jinja | 22 ++++++++++++++++++- counter/views.py | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/counter/templates/counter/cash_summary_list.jinja b/counter/templates/counter/cash_summary_list.jinja index 7ea832b6..a9432d06 100644 --- a/counter/templates/counter/cash_summary_list.jinja +++ b/counter/templates/counter/cash_summary_list.jinja @@ -38,7 +38,7 @@ - {% for c in cashsummary_list.order_by('-date') %} + {% for c in cashsummary_list %} {{ user_profile_link(c.user) }} {{ c.counter }} @@ -55,6 +55,26 @@ {% endfor %} +
+{% if is_paginated %} + {% if page_obj.has_previous() %} + {% trans %}Previous{% endtrans %} + {% else %} + {% trans %}Previous{% endtrans %} + {% endif %} + {% for i in paginator.page_range %} + {% if page_obj.number == i %} + {{ i }} ({% trans %}current{% endtrans %}) + {% else %} + {{ i }} + {% endif %} + {% endfor %} + {% if page_obj.has_next() %} + {% trans %}Next{% endtrans %} + {% else %} + {% trans %}Next{% endtrans %} + {% endif %} +{% endif %} {% else %} {% trans %}There is no cash register summary in this website.{% endtrans %} {% endif %} diff --git a/counter/views.py b/counter/views.py index ed97a84e..5fd114ff 100644 --- a/counter/views.py +++ b/counter/views.py @@ -938,6 +938,8 @@ class CashSummaryListView(CanEditPropMixin, CounterAdminTabsMixin, ListView): template_name = 'counter/cash_summary_list.jinja' context_object_name = "cashsummary_list" current_tab = "cash_summary" + queryset = CashRegisterSummary.objects.all().order_by('-date') + paginate_by = 10 def get_context_data(self, **kwargs): """ Add sums to the context """