diff --git a/cotisations/views.py b/cotisations/views.py index 29162353..5debb53f 100644 --- a/cotisations/views.py +++ b/cotisations/views.py @@ -387,4 +387,14 @@ def history(request, object, id): messages.error(request, "Objet inconnu") return redirect("/cotisations/") reversions = reversion.get_for_object(object_instance) + paginator = Paginator(reversions, PAGINATION_NUMBER) + page = request.GET.get('page') + try: + reversions = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + reversions = paginator.page(1) + except EmptyPage: + # If page is out of range (e.g. 9999), deliver last page of results. + reversions = paginator.page(paginator.num_pages) return render(request, 're2o/history.html', {'reversions': reversions, 'object': object_instance}) diff --git a/machines/views.py b/machines/views.py index b77250b1..5843a88f 100644 --- a/machines/views.py +++ b/machines/views.py @@ -22,7 +22,7 @@ import re from .forms import NewMachineForm, EditMachineForm, EditInterfaceForm, AddInterfaceForm, MachineTypeForm, DelMachineTypeForm, ExtensionForm, DelExtensionForm, BaseEditInterfaceForm, BaseEditMachineForm from .models import Machine, Interface, IpList, MachineType, Extension from users.models import User -from re2o.settings import PAGINATION_NUMBER +from re2o.settings import PAGINATION_NUMBER, PAGINATION_LARGE_NUMBER def full_domain_validator(request, interface): """ Validation du nom de domaine, extensions dans type de machine, prefixe pas plus long que 63 caractères """ @@ -315,7 +315,7 @@ def del_extension(request): @permission_required('cableur') def index(request): machines_list = Machine.objects.order_by('pk') - paginator = Paginator(machines_list, PAGINATION_NUMBER) + paginator = Paginator(machines_list, PAGINATION_LARGE_NUMBER) page = request.GET.get('page') try: machines_list = paginator.page(page) @@ -375,6 +375,16 @@ def history(request, object, id): messages.error(request, "Objet inconnu") return redirect("/machines/") reversions = reversion.get_for_object(object_instance) + paginator = Paginator(reversions, PAGINATION_NUMBER) + page = request.GET.get('page') + try: + reversions = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + reversions = paginator.page(1) + except EmptyPage: + # If page is out of range (e.g. 9999), deliver last page of results. + reversions = paginator.page(paginator.num_pages) return render(request, 're2o/history.html', {'reversions': reversions, 'object': object_instance}) diff --git a/re2o/settings.py b/re2o/settings.py index 2d2d29bf..de49c713 100644 --- a/re2o/settings.py +++ b/re2o/settings.py @@ -133,4 +133,6 @@ RIGHTS_LINK = { 'bofh' : ['bureau','trésorier'], } -PAGINATION_NUMBER = 5 +PAGINATION_NUMBER = 25 + +PAGINATION_LARGE_NUMBER = 8 diff --git a/re2o/templates/re2o/aff_history.html b/re2o/templates/re2o/aff_history.html index d2019c67..10287f0d 100644 --- a/re2o/templates/re2o/aff_history.html +++ b/re2o/templates/re2o/aff_history.html @@ -1,3 +1,18 @@ + {% if reversions.paginator %} + + {% endif %} + diff --git a/topologie/views.py b/topologie/views.py index 127add5f..cd1eca54 100644 --- a/topologie/views.py +++ b/topologie/views.py @@ -3,12 +3,15 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required, permission_required from django.db import IntegrityError from django.db import transaction +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from reversion import revisions as reversion from topologie.models import Switch, Port, Room from topologie.forms import EditPortForm, EditSwitchForm, AddPortForm, EditRoomForm from users.views import form +from re2o.settings import PAGINATION_NUMBER + @login_required @permission_required('cableur') def index(request): @@ -40,6 +43,16 @@ def history(request, object, id): messages.error(request, "Objet inconnu") return redirect("/topologie/") reversions = reversion.get_for_object(object_instance) + paginator = Paginator(reversions, PAGINATION_NUMBER) + page = request.GET.get('page') + try: + reversions = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + reversions = paginator.page(1) + except EmptyPage: + # If page is out of range (e.g. 9999), deliver last page of results. + reversions = paginator.page(paginator.num_pages) return render(request, 're2o/history.html', {'reversions': reversions, 'object': object_instance}) @login_required diff --git a/users/views.py b/users/views.py index 979f983f..145d18f2 100644 --- a/users/views.py +++ b/users/views.py @@ -467,6 +467,16 @@ def history(request, object, id): messages.error(request, "Objet inconnu") return redirect("/users/") reversions = reversion.get_for_object(object_instance) + paginator = Paginator(reversions, PAGINATION_NUMBER) + page = request.GET.get('page') + try: + reversions = paginator.page(page) + except PageNotAnInteger: + # If page is not an integer, deliver first page. + reversions = paginator.page(1) + except EmptyPage: + # If page is out of range (e.g. 9999), deliver last page of results. + reversions = paginator.page(paginator.num_pages) return render(request, 're2o/history.html', {'reversions': reversions, 'object': object_instance})