diff --git a/uniticket/uni_ticket/views/management.py b/uniticket/uni_ticket/views/management.py index 493c0a51..7eb9d015 100644 --- a/uniticket/uni_ticket/views/management.py +++ b/uniticket/uni_ticket/views/management.py @@ -446,7 +446,9 @@ def tickets(request, structure_slug, structure, office_employee=None): # if user is operator if office_employee: ticket_list = visible_tickets_to_user( - user=request.user, structure=structure, office_employee=office_employee + user=request.user, + structure=structure, + office_employee=office_employee ) tickets = Ticket.objects.filter(code__in=ticket_list) @@ -454,21 +456,25 @@ def tickets(request, structure_slug, structure, office_employee=None): # unassigned = [] # opened = [] # my_opened = [] - unassigned = 0 - opened = 0 - my_opened = 0 + unassigned = False + opened = False + my_opened = False 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 += 1 + opened = True if nc.has_been_taken_by_user(structure=structure, user=request.user): # my_opened.append(nc) - my_opened += 1 + my_opened = True else: # unassigned.append(nc) - unassigned += 1 + unassigned = True # chiusi = Ticket.objects.filter(code__in=ticket_list, is_closed=True) - chiusi = tickets.filter(is_closed=True).count() + # chiusi = tickets.filter(is_closed=True).count() ticket_codes = not_closed.values_list('ticket__code', flat=True) # if user is manager else: @@ -479,9 +485,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).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() + 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() 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 98a73704..a29db07a 100644 --- a/uniticket/uni_ticket/views/manager.py +++ b/uniticket/uni_ticket/views/manager.py @@ -49,10 +49,6 @@ def dashboard(request, structure_slug, structure): "Gestisci le richieste per la struttura {}").format(structure) template = "manager/dashboard.html" - # ta = TicketAssignment - # structure_tickets = ta.get_ticket_per_structure(structure=structure) - # tickets = Ticket.objects.filter(code__in=structure_tickets) - assignments = TicketAssignment.objects.filter( office__organizational_structure=structure, office__is_active=True, @@ -60,21 +56,20 @@ 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).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() + 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() + om = OrganizationalStructureOffice offices = om.objects.filter(organizational_structure=structure) cm = TicketCategory categories = cm.objects.filter(organizational_structure=structure)\ .select_related('organizational_office') - # disabled_expired_items(categories) - # messages = TicketReply.get_unread_messages_count(tickets=tickets) ticket_codes = assignments.filter(ticket__is_closed=False).values_list('ticket__code', flat=True).distinct() messages = TicketReply.get_unread_messages_count(ticket_codes=ticket_codes) - # messages = 0 + d = { "categories": categories, "offices": offices, diff --git a/uniticket/uni_ticket/views/operator.py b/uniticket/uni_ticket/views/operator.py index 3ae912bf..8f4f9480 100644 --- a/uniticket/uni_ticket/views/operator.py +++ b/uniticket/uni_ticket/views/operator.py @@ -36,16 +36,20 @@ def dashboard(request, structure_slug, structure, office_employee): ) tickets = Ticket.objects.filter(code__in=user_tickets) not_closed = tickets.filter(is_closed=False) - unassigned = 0 - opened = 0 - my_opened = 0 + unassigned = False + opened = False + my_opened = False for nc in not_closed: + if unassigned and opened and my_opened: + break if nc.has_been_taken(): - opened += 1 + if opened and my_opened: + continue + opened = True if nc.has_been_taken_by_user(structure=structure, user=request.user): - my_opened += 1 + my_opened = True else: - unassigned += 1 + unassigned = True # chiusi = tickets.filter(is_closed=True).count() ticket_codes = not_closed.values_list('ticket__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 bb6f089d..a842388e 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 %} - {{ ticket_non_gestiti }} {% trans 'Aperte' %} + {% trans 'Aperte' %} - - {{ ticket_aperti }} {% trans 'Assegnate' %} - ({{ ticket_assegnati_a_me }} {% trans 'a me' %}) + + {% trans 'Assegnate' %} + {% if ticket_assegnati_a_me %}({% trans 'anche a me' %}){% endif %} {% 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 98e6ef8f..f9cc8c86 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,22 +3,16 @@
  • - {% 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 > 0 %} -
    ({{ ticket_assegnati_a_me }} {% trans 'a me' %}) + {% if ticket_assegnati_a_me %} +
    ({% trans 'anche 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 3a547e94..d574ee1d 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,16 +242,15 @@