Paginateurs
This commit is contained in:
parent
f85829e69c
commit
c086635490
|
@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% if auteurs_list.paginator %}
|
||||||
|
{% include "pagination.html" with list=auteurs_list %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -22,6 +22,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
{% endcomment %}
|
{% endcomment %}
|
||||||
|
|
||||||
|
{% if medias_list.paginator %}
|
||||||
|
{% include "pagination.html" with list=medias_list %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<table class="table table-striped">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
|
@ -16,7 +16,7 @@ from django.db import transaction
|
||||||
from reversion import revisions as reversion
|
from reversion import revisions as reversion
|
||||||
from reversion.models import Version
|
from reversion.models import Version
|
||||||
|
|
||||||
from med.settings import PAGINATION_NUMBER as pagination_number
|
from med.settings import PAGINATION_NUMBER
|
||||||
|
|
||||||
def form(ctx, template, request):
|
def form(ctx, template, request):
|
||||||
c = ctx
|
c = ctx
|
||||||
|
@ -200,11 +200,31 @@ def del_emprunt(request, empruntid):
|
||||||
@login_required
|
@login_required
|
||||||
def index_auteurs(request):
|
def index_auteurs(request):
|
||||||
auteurs_list = Auteur.objects.all()
|
auteurs_list = Auteur.objects.all()
|
||||||
|
paginator = Paginator(auteurs_list, PAGINATION_NUMBER)
|
||||||
|
page = request.GET.get('page')
|
||||||
|
try:
|
||||||
|
auteurs_list = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
# If page is not an integer, deliver first page.
|
||||||
|
auteurs_list = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
|
auteurs_list = paginator.page(paginator.num_pages)
|
||||||
return render(request, 'media/index_auteurs.html', {'auteurs_list':auteurs_list})
|
return render(request, 'media/index_auteurs.html', {'auteurs_list':auteurs_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def index_medias(request):
|
def index_medias(request):
|
||||||
medias_list = Media.objects.all()
|
medias_list = Media.objects.all()
|
||||||
|
paginator = Paginator(medias_list, PAGINATION_NUMBER)
|
||||||
|
page = request.GET.get('page')
|
||||||
|
try:
|
||||||
|
medias_list = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
# If page is not an integer, deliver first page.
|
||||||
|
medias_list = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
|
medias_list = paginator.page(paginator.num_pages)
|
||||||
return render(request, 'media/index_medias.html', {'medias_list':medias_list})
|
return render(request, 'media/index_medias.html', {'medias_list':medias_list})
|
||||||
|
|
||||||
|
|
||||||
|
@ -238,7 +258,7 @@ def history(request, object, id):
|
||||||
messages.error(request, "Emprunt inexistant")
|
messages.error(request, "Emprunt inexistant")
|
||||||
return redirect("/media/index_emprunts")
|
return redirect("/media/index_emprunts")
|
||||||
reversions = Version.objects.get_for_object(object_instance)
|
reversions = Version.objects.get_for_object(object_instance)
|
||||||
paginator = Paginator(reversions, pagination_number)
|
paginator = Paginator(reversions, PAGINATION_NUMBER)
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
try:
|
try:
|
||||||
reversions = paginator.page(page)
|
reversions = paginator.page(page)
|
||||||
|
|
Loading…
Reference in New Issue