mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-23 20:03:11 +00:00
PAginateurs sur l'historique
This commit is contained in:
parent
b57ef3eedb
commit
5c14ac1f58
6 changed files with 63 additions and 3 deletions
|
@ -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})
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
||||
|
|
|
@ -133,4 +133,6 @@ RIGHTS_LINK = {
|
|||
'bofh' : ['bureau','trésorier'],
|
||||
}
|
||||
|
||||
PAGINATION_NUMBER = 5
|
||||
PAGINATION_NUMBER = 25
|
||||
|
||||
PAGINATION_LARGE_NUMBER = 8
|
||||
|
|
|
@ -1,3 +1,18 @@
|
|||
{% if reversions.paginator %}
|
||||
<ul class="pagination nav navbar-nav">
|
||||
{% if reversions.has_previous %}
|
||||
<li><a href="?page={{ reversions.previous_page_number }}">Suivants</a></li>
|
||||
{% endif %}
|
||||
{% for page in reversions.paginator.page_range %}
|
||||
<li class="{% if reversions.number == page %}active{% endif %}"><a href="?page={{page }}">{{ page }}</a></li>
|
||||
{% endfor %}
|
||||
|
||||
{% if reversions.has_next %}
|
||||
<li> <a href="?page={{ reversions.next_page_number }}">Précédents</a></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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})
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue