From a3cf3630cd6018b5b6e9361195e8ae8ff3fe4f53 Mon Sep 17 00:00:00 2001 From: Francesco Filicetti Date: Thu, 2 Nov 2023 09:07:44 +0100 Subject: [PATCH] fix: restore counters --- uniticket/uni_ticket/views/management.py | 28 ++++++------------- uniticket/uni_ticket/views/manager.py | 6 ++-- uniticket/uni_ticket/views/operator.py | 16 ++++------- .../templates/management/ticket_cards.html | 10 +++---- .../management/ticket_cards_mobile.html | 14 +++++++--- .../templates/management/ticket_detail.html | 12 ++++---- .../templates/manager/dashboard.html | 2 +- .../templates/user/dashboard.html | 24 ++++++++++------ .../templates/user/ticket_detail.html | 4 +-- 9 files changed, 57 insertions(+), 59 deletions(-) diff --git a/uniticket/uni_ticket/views/management.py b/uniticket/uni_ticket/views/management.py index 23852b71..4bd0948c 100644 --- a/uniticket/uni_ticket/views/management.py +++ b/uniticket/uni_ticket/views/management.py @@ -453,26 +453,16 @@ def tickets(request, structure_slug, structure, office_employee=None): tickets = Ticket.objects.filter(code__in=ticket_list) not_closed = tickets.filter(is_closed=False) - # unassigned = [] - # opened = [] - # my_opened = [] - unassigned = False - opened = False - my_opened = False + unassigned = 0 + opened = 0 + my_opened = 0 for nc in not_closed: - if unassigned and opened and my_opened: - break if nc.has_been_taken(): - if opened and my_opened: - continue - # opened.append(nc) - opened = True + opened += 1 if nc.has_been_taken_by_user(structure=structure, user=request.user): - # my_opened.append(nc) - my_opened = True + my_opened += 1 else: - # unassigned.append(nc) - unassigned = True + unassigned += 1 # chiusi = Ticket.objects.filter(code__in=ticket_list, is_closed=True) # chiusi = tickets.filter(is_closed=True).count() ticket_codes = not_closed.values_list('code', flat=True) @@ -485,9 +475,9 @@ def tickets(request, structure_slug, structure, office_employee=None): ).select_related('ticket') # chiusi = assignments.filter(ticket__is_closed=True).values('ticket__code').annotate(total=Count('ticket__code')).count() - opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False).exists() - unassigned = assignments.filter(ticket__assigned_date__isnull=True, ticket__is_closed=False).exists() - my_opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False, taken_by=request.user).exists() + opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False).values('ticket__code').annotate(total=Count('ticket__code')).count() + unassigned = assignments.filter(ticket__assigned_date__isnull=True, ticket__is_closed=False).values('ticket__code').annotate(total=Count('ticket__code')).count() + my_opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False, taken_by=request.user).values('ticket__code').annotate(total=Count('ticket__code')).count() ticket_codes = assignments.filter(ticket__is_closed=False).values_list('ticket__code', flat=True) # unread messages diff --git a/uniticket/uni_ticket/views/manager.py b/uniticket/uni_ticket/views/manager.py index 908896e2..8d241a9c 100644 --- a/uniticket/uni_ticket/views/manager.py +++ b/uniticket/uni_ticket/views/manager.py @@ -56,9 +56,9 @@ def dashboard(request, structure_slug, structure): ).select_related('ticket').values('ticket') # chiusi = assignments.filter(ticket__is_closed=True).annotate(total=Count('ticket__code')).count() - opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False).exists() - unassigned = assignments.filter(ticket__assigned_date__isnull=True, ticket__is_closed=False).exists() - my_opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False, taken_by=request.user).exists() + opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False).annotate(total=Count('ticket__code')).count() + unassigned = assignments.filter(ticket__assigned_date__isnull=True, ticket__is_closed=False).annotate(total=Count('ticket__code')).count() + my_opened = assignments.filter(ticket__assigned_date__isnull=False, ticket__is_closed=False, taken_by=request.user).annotate(total=Count('ticket__code')).count() om = OrganizationalStructureOffice offices = om.objects.filter(organizational_structure=structure)\ diff --git a/uniticket/uni_ticket/views/operator.py b/uniticket/uni_ticket/views/operator.py index 8cf1df4d..bbe98131 100644 --- a/uniticket/uni_ticket/views/operator.py +++ b/uniticket/uni_ticket/views/operator.py @@ -36,20 +36,16 @@ def dashboard(request, structure_slug, structure, office_employee): ) tickets = Ticket.objects.filter(code__in=user_tickets) not_closed = tickets.filter(is_closed=False) - unassigned = False - opened = False - my_opened = False + unassigned = 0 + opened = 0 + my_opened = 0 for nc in not_closed: - if unassigned and opened and my_opened: - break if nc.has_been_taken(): - if opened and my_opened: - continue - opened = True + opened += 1 if nc.has_been_taken_by_user(structure=structure, user=request.user): - my_opened = True + my_opened += 1 else: - unassigned = True + unassigned += 1 # chiusi = tickets.filter(is_closed=True).count() ticket_codes = not_closed.values_list('code', flat=True).distinct() diff --git a/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards.html b/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards.html index a842388e..bb6f089d 100644 --- a/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards.html +++ b/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards.html @@ -2,13 +2,13 @@ {% load static %} - {% trans 'Aperte' %} + {{ ticket_non_gestiti }} {% trans 'Aperte' %} - - {% trans 'Assegnate' %} - {% if ticket_assegnati_a_me %}({% trans 'anche a me' %}){% endif %} + + {{ ticket_aperti }} {% trans 'Assegnate' %} + ({{ ticket_assegnati_a_me }} {% trans 'a me' %}) {% trans 'Chiuse' %} diff --git a/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards_mobile.html b/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards_mobile.html index f9cc8c86..98e6ef8f 100644 --- a/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards_mobile.html +++ b/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_cards_mobile.html @@ -3,16 +3,22 @@
  • - + {% if ticket_non_gestiti > 0 %} +
    {{ ticket_non_gestiti }}
    + {% endif %} + {% trans 'Aperte' %}
  • - + {% if ticket_aperti > 0 %} +
    {{ ticket_aperti }}
    + {% endif %} + {% trans 'Assegnate' %} - {% if ticket_assegnati_a_me %} -
    ({% trans 'anche a me' %}) + {% if ticket_assegnati_a_me > 0 %} +
    ({{ ticket_assegnati_a_me }} {% trans 'a me' %}) {% endif %}
    diff --git a/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_detail.html b/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_detail.html index d574ee1d..aaf64824 100644 --- a/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_detail.html +++ b/uniticket/uni_ticket_bootstrap_italia_template/templates/management/ticket_detail.html @@ -242,15 +242,15 @@