From 49184d32d63a59b663233effcf205257fe2ec59d Mon Sep 17 00:00:00 2001 From: Grizzly Date: Tue, 6 Aug 2019 19:27:03 +0000 Subject: [PATCH] pagination --- tickets/templates/tickets/aff_tickets.html | 11 +++++++++-- tickets/views.py | 23 ++++++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/tickets/templates/tickets/aff_tickets.html b/tickets/templates/tickets/aff_tickets.html index 1d447234..401d1c3c 100644 --- a/tickets/templates/tickets/aff_tickets.html +++ b/tickets/templates/tickets/aff_tickets.html @@ -37,7 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ nbr_tickets }} {% trans "Tickets" %}
- {{ nbr_tickets_unsolved }}{% trans "Not Solved Tickets" %} + {{ nbr_tickets_unsolved }}{% trans "Not Solved Tickets" %}
{% trans "Last Ticket:" %} {{ last_ticket_date }} @@ -46,8 +46,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
+ +
- + +
@@ -76,5 +79,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
+ + {% if tickets_list.paginator %} + {% include 'pagination.html' with list=tickets_list go_to_id="tickets" %} + {% endif %}
{% endblock %} diff --git a/tickets/views.py b/tickets/views.py index 7a86ecf4..e5dd14a5 100644 --- a/tickets/views.py +++ b/tickets/views.py @@ -5,6 +5,11 @@ from django.urls import reverse from django.forms import modelformset_factory from re2o.views import form +from re2o.base import ( + re2o_paginator, +) + +from preferences.models import GeneralOption from .models import( Ticket, Preferences, @@ -56,10 +61,20 @@ def aff_ticket(request,ticketid): def aff_tickets(request): """ Vue d'affichage de tout les tickets """ - tickets = Ticket.objects.all().order_by('-date') - last_ticket_date = tickets.first().date - nbr_tickets = tickets.count() - nbr_tickets_unsolved = Ticket.objects.filter(solved=False).count() + tickets_list = Ticket.objects.all().order_by('-date') + last_ticket_date = tickets_list.first().date + nbr_tickets = tickets_list.count() + nbr_tickets_unsolved = tickets_list.filter(solved=False).count() + + pagination_number = (GeneralOption + .get_cached_value('pagination_number')) + + tickets = re2o_paginator( + request, + tickets_list, + pagination_number, + ) + context = {'tickets_list':tickets, 'last_ticket_date':last_ticket_date, 'nbr_tickets':nbr_tickets,