8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-11-27 15:12:25 +00:00

Pagination sur le controle des factures

This commit is contained in:
Dalahro 2016-11-18 11:31:33 +01:00
parent c541bfcfd9
commit 104b466e1e
2 changed files with 14 additions and 2 deletions

View file

@ -6,6 +6,9 @@
{% block content %} {% block content %}
<h2>Controle et validité des factures</h2> <h2>Controle et validité des factures</h2>
{% if facture_list.paginator %}
{% include "pagination.html" with list=facture_list %}
{% endif %}
<form class="form" method="post"> <form class="form" method="post">
{% csrf_token %} {% csrf_token %}
{{ controlform.management_form }} {{ controlform.management_form }}

View file

@ -315,11 +315,20 @@ def del_banque(request):
def control(request): def control(request):
facture_list = Facture.objects.order_by('date').reverse() facture_list = Facture.objects.order_by('date').reverse()
controlform_set = modelformset_factory(Facture, fields=('control','valid'), extra=0) controlform_set = modelformset_factory(Facture, fields=('control','valid'), extra=0)
controlform = controlform_set(request.POST or None, queryset=facture_list) paginator = Paginator(facture_list, PAGINATION_NUMBER)
page = request.GET.get('page')
try:
facture_list = paginator.page(page)
except PageNotAnInteger:
facture_list = paginator.page(1)
except EmptyPage:
facture_list = paginator.page(paginator.num.pages)
page_query = Facture.objects.order_by('date').reverse().filter(id__in=[facture.id for facture in facture_list])
controlform = controlform_set(request.POST or None, queryset=page_query)
if controlform.is_valid(): if controlform.is_valid():
controlform.save() controlform.save()
return redirect("/cotisations/control/") return redirect("/cotisations/control/")
return render(request, 'cotisations/control.html', {'controlform': controlform}) return render(request, 'cotisations/control.html', {'facture_list': facture_list, 'controlform': controlform})
@login_required @login_required
@permission_required('cableur') @permission_required('cableur')