mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-28 09:53:47 +00:00
Pagination sur le controle des factures
This commit is contained in:
parent
c541bfcfd9
commit
104b466e1e
2 changed files with 14 additions and 2 deletions
|
@ -6,6 +6,9 @@
|
|||
|
||||
{% block content %}
|
||||
<h2>Controle et validité des factures</h2>
|
||||
{% if facture_list.paginator %}
|
||||
{% include "pagination.html" with list=facture_list %}
|
||||
{% endif %}
|
||||
<form class="form" method="post">
|
||||
{% csrf_token %}
|
||||
{{ controlform.management_form }}
|
||||
|
|
|
@ -315,11 +315,20 @@ def del_banque(request):
|
|||
def control(request):
|
||||
facture_list = Facture.objects.order_by('date').reverse()
|
||||
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():
|
||||
controlform.save()
|
||||
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
|
||||
@permission_required('cableur')
|
||||
|
|
Loading…
Reference in a new issue