Merge branch 'counter' into 'master'

Pagination for cash sumary

See merge request !53
This commit is contained in:
Skia 2017-03-14 17:39:03 +01:00
commit 5e0f790247
3 changed files with 26 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 = settings.SITH_COUNTER_CASH_SUMMARY_LENGTH
def get_context_data(self, **kwargs):
""" Add sums to the context """

View File

@ -357,6 +357,9 @@ SITH_COUNTER_BANK = [
('LA-POSTE', 'La Poste'),
]
# Defines pagination for cash summary
SITH_COUNTER_CASH_SUMMARY_LENGTH = 50
# Defines which product type is the refilling type, and thus increases the account amount
SITH_COUNTER_PRODUCTTYPE_REFILLING = 11