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 %} +