mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-26 08:53:46 +00:00
Mise en place de la pagination sur la liste des bannissements, et classement par ordre de date décroissante
This commit is contained in:
parent
74d264e455
commit
6d5a7267c1
2 changed files with 15 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
{% if ban_list.paginator %}
|
||||||
|
{% include "pagination.html" with list=ban_list %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -402,7 +402,17 @@ def index(request):
|
||||||
@login_required
|
@login_required
|
||||||
@permission_required('cableur')
|
@permission_required('cableur')
|
||||||
def index_ban(request):
|
def index_ban(request):
|
||||||
ban_list = Ban.objects.order_by('date_start')
|
ban_list = Ban.objects.order_by('date_start').reverse()
|
||||||
|
paginator = Paginator(ban_list, PAGINATION_NUMBER)
|
||||||
|
page = request.GET.get('page')
|
||||||
|
try:
|
||||||
|
ban_list = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
# If page isn't an integer, deliver first page
|
||||||
|
ban_list = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
|
ban_list = paginator.page(paginator.num_pages)
|
||||||
return render(request, 'users/index_ban.html', {'ban_list': ban_list})
|
return render(request, 'users/index_ban.html', {'ban_list': ban_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
|
|
Loading…
Reference in a new issue