diff --git a/helpdesk/templates/helpdesk/dashboard.html b/helpdesk/templates/helpdesk/dashboard.html index 3a904a02..79225c6c 100644 --- a/helpdesk/templates/helpdesk/dashboard.html +++ b/helpdesk/templates/helpdesk/dashboard.html @@ -16,18 +16,21 @@ {% if all_tickets_reported_by_current_user %} {% trans "All Tickets submitted by you" as ticket_list_caption %} -{% include 'helpdesk/include/tickets.html' with ticket_list=all_tickets_reported_by_current_user ticket_list_empty_message="" %} +{% trans "atrbcu_page" as page_var} +{% include 'helpdesk/include/tickets.html' with ticket_list=all_tickets_reported_by_current_user ticket_list_empty_message="" page_var=page_var %} {% endif %} {% trans "Open Tickets assigned to you (you are working on this ticket)" as ticket_list_caption %} {% trans "You have no tickets assigned to you." as no_assigned_tickets %} -{% include 'helpdesk/include/tickets.html' with ticket_list=user_tickets ticket_list_empty_message=no_assigned_tickets %} +{% trans "ut_page" as page_var} +{% include 'helpdesk/include/tickets.html' with ticket_list=user_tickets ticket_list_empty_message=no_assigned_tickets page_var=page_var %} {% include 'helpdesk/include/unassigned.html' %} {% if user_tickets_closed_resolved %} {% trans "Closed & resolved Tickets you used to work on" as ticket_list_caption %} -{% include 'helpdesk/include/tickets.html' with ticket_list=user_tickets_closed_resolved ticket_list_empty_message="" %} +{% trans "utcr_page" as page_var} +{% include 'helpdesk/include/tickets.html' with ticket_list=user_tickets_closed_resolved ticket_list_empty_message="" page_var=page_var %} {% endif %} {% endblock %} diff --git a/helpdesk/templates/helpdesk/include/tickets.html b/helpdesk/templates/helpdesk/include/tickets.html index 6d5097b3..b81ab0c9 100644 --- a/helpdesk/templates/helpdesk/include/tickets.html +++ b/helpdesk/templates/helpdesk/include/tickets.html @@ -37,6 +37,27 @@ + {% if ticket_list.has_other_pages %} + + {% endif %} diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index ff496156..ba85af52 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -15,6 +15,7 @@ from django.conf import settings from django.contrib.auth import get_user_model from django.urls import reverse from django.core.exceptions import ValidationError, PermissionDenied +from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.db.models import Q from django.http import HttpResponseRedirect, Http404, HttpResponse from django.shortcuts import render, get_object_or_404 @@ -91,6 +92,15 @@ def dashboard(request): showing ticket counts by queue/status, and a list of unassigned tickets with options for them to 'Take' ownership of said tickets. """ + + # user settings num tickets per page + tickets_per_page = request.user.usersettings_helpdesk.tickets_per_page + + # page vars for the three ticket tables + user_tickets_page = request.GET.get('ut_page', 1) + user_tickets_closed_resolved_page = request.GET.get('utcr_page', 1) + all_tickets_reported_by_current_user_page = request.GET.get('atrbcu_page', 1) + # open & reopened tickets, assigned to current user tickets = Ticket.objects.select_related('queue').filter( assigned_to=request.user, @@ -141,6 +151,41 @@ def dashboard(request): else: where_clause = """WHERE q.id = t.queue_id""" + # get user assigned tickets page + paginator = Paginator( + tickets, tickets_per_page) + try: + tickets = paginator.page(user_tickets_page) + except PageNotAnInteger: + tickets = paginator.page(1) + except EmptyPage: + tickets = paginator.page( + paginator.num_pages) + + # get user completed tickets page + paginator = Paginator( + tickets_closed_resolved, tickets_per_page) + try: + tickets_closed_resolved = paginator.page( + user_tickets_closed_resolved_page) + except PageNotAnInteger: + tickets_closed_resolved = paginator.page(1) + except EmptyPage: + tickets_closed_resolved = paginator.page( + paginator.num_pages) + + # get user submitted tickets page + paginator = Paginator( + all_tickets_reported_by_current_user, tickets_per_page) + try: + all_tickets_reported_by_current_user = paginator.page( + all_tickets_reported_by_current_user_page) + except PageNotAnInteger: + all_tickets_reported_by_current_user = paginator.page(1) + except EmptyPage: + all_tickets_reported_by_current_user = paginator.page( + paginator.num_pages) + return render(request, 'helpdesk/dashboard.html', { 'user_tickets': tickets, 'user_tickets_closed_resolved': tickets_closed_resolved,