Pagination for cash sumary

This commit is contained in:
Antoine Bartuccio 2017-03-13 16:32:59 +01:00
parent 3fd4d4b04b
commit e4deacbe56
2 changed files with 23 additions and 1 deletions

View File

@ -38,7 +38,7 @@
</tr>
</thead>
<tbody>
{% for c in cashsummary_list.order_by('-date') %}
{% for c in cashsummary_list %}
<tr>
<td>{{ user_profile_link(c.user) }}</td>
<td>{{ c.counter }}</td>
@ -55,6 +55,26 @@
{% endfor %}
</tbody>
</table>
<br>
{% if is_paginated %}
{% if page_obj.has_previous() %}
<a href="?page={{ page_obj.previous_page_number() }}">{% trans %}Previous{% endtrans %}</a>
{% else %}
<span class="disabled">{% trans %}Previous{% endtrans %}</span>
{% endif %}
{% for i in paginator.page_range %}
{% if page_obj.number == i %}
<span class="active">{{ i }} <span class="sr-only">({% trans %}current{% endtrans %})</span></span>
{% else %}
<a href="?page={{ i }}">{{ i }}</a>
{% endif %}
{% endfor %}
{% if page_obj.has_next() %}
<a href="?page={{ page_obj.next_page_number() }}">{% trans %}Next{% endtrans %}</a>
{% else %}
<span class="disabled">{% trans %}Next{% endtrans %}</span>
{% endif %}
{% endif %}
{% else %}
{% trans %}There is no cash register summary in this website.{% endtrans %}
{% endif %}

View File

@ -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 """