Skip to content

Commit

Permalink
fix: restore counters
Browse files Browse the repository at this point in the history
  • Loading branch information
francesco-filicetti committed Nov 2, 2023
1 parent a877b10 commit a3cf363
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 59 deletions.
28 changes: 9 additions & 19 deletions uniticket/uni_ticket/views/management.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions uniticket/uni_ticket/views/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)\
Expand Down
16 changes: 6 additions & 10 deletions uniticket/uni_ticket/views/operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{% load static %}

<a role="button"
class="btn btn-outline-{% if ticket_aperti %}warning{% else %}secondary{% endif %}"
class="btn btn-outline-secondary"
href="{% url 'uni_ticket:manage_unassigned_ticket_url' structure_slug=structure.slug %}">
{% trans 'Aperte' %}
<span class="badge badge-light">{{ ticket_non_gestiti }}</span> {% trans 'Aperte' %}
</a>
<a role="button" class="btn btn-outline-{% if ticket_aperti %}warning{% else %}secondary{% endif %}" href="{% url 'uni_ticket:manage_opened_ticket_url' structure_slug=structure.slug %}">
{% trans 'Assegnate' %}
{% if ticket_assegnati_a_me %}({% trans 'anche a me' %}){% endif %}
<a role="button" class="btn btn-outline-secondary" href="{% url 'uni_ticket:manage_opened_ticket_url' structure_slug=structure.slug %}">
<span class="badge badge-light">{{ ticket_aperti }}</span> {% trans 'Assegnate' %}
(<span class="badge badge-light">{{ ticket_assegnati_a_me }}</span> {% trans 'a me' %})
</a>
<a role="button" class="btn btn-outline-secondary" href="{% url 'uni_ticket:manage_closed_ticket_url' structure_slug=structure.slug %}">
{% trans 'Chiuse' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@

<li>
<a href="{% url 'uni_ticket:manage_unassigned_ticket_url' structure_slug=structure.slug %}">
<svg class="icon {% if ticket_non_gestiti %}icon-warning{% endif %}"><use xlink:href="{% static 'svg/sprite.svg' %}#it-warning-circle"></use></svg>
{% if ticket_non_gestiti > 0 %}
<div class="badge-wrapper"><span class="toolbar-badge badge-primary">{{ ticket_non_gestiti }}</span></div>
{% endif %}
<svg class="icon"><use xlink:href="{% static 'svg/sprite.svg' %}#it-warning-circle"></use></svg>
<span class="toolbar-label">{% trans 'Aperte' %}</span></span>
</a>
</li>
<li>
<a href="{% url 'uni_ticket:manage_opened_ticket_url' structure_slug=structure.slug %}">
<svg class="icon {% if ticket_aperti %}icon-warning{% endif %}"><use xlink:href="{% static 'svg/sprite.svg' %}#it-clock"></use></svg>
{% if ticket_aperti > 0 %}
<div class="badge-wrapper"><span class="toolbar-badge">{{ ticket_aperti }}</span></div>
{% endif %}
<svg class="icon"><use xlink:href="{% static 'svg/sprite.svg' %}#it-clock"></use></svg>
<span class="toolbar-label">{% trans 'Assegnate' %}
{% if ticket_assegnati_a_me %}
<br>({% trans 'anche a me' %})
{% if ticket_assegnati_a_me > 0 %}
<br>({{ ticket_assegnati_a_me }} {% trans 'a me' %})
{% endif %}
</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,15 +242,15 @@ <h5 class="modal-title">
</div>

{% if ticket_taken %}
{% with ticket.get_messages_count.1 as unread_messages %}
<a role="button"
href="{% url 'uni_ticket:manage_ticket_message_url' structure_slug=structure.slug ticket_id=ticket.code %}"
class="btn btn-outline-{% if unread_messages > 0 %}warning{% else %}secondary{% endif %}">
<svg class="icon icon-xs">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use>
</svg> {% trans "Messaggi" %}
class="btn btn-outline-secondary">
{% with ticket.get_messages_count.1 as unread_messages %}
<svg class="icon icon-xs {% if unread_messages > 0 %}icon-warning{% endif %}">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use>
</svg> {% trans "Messaggi" %}
{% endwith %}
</a>
{% endwith %}
{% endif %}

{% if ticket_taken and ticket.is_closed and not ticket.is_notification %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="pb-4 clearfix">
<div class="pull-left d-none d-md-block">
{% include 'management/ticket_cards.html' %}
<a role="button" class="btn btn-outline-{% if ticket_aperti %}warning{% else %}secondary{% endif %}" href="{% url 'uni_ticket:manager_messages' structure_slug=structure.slug %}">
<a role="button" class="btn btn-outline-{% if ticket_messages %}warning{% else %}secondary{% endif %}" href="{% url 'uni_ticket:manager_messages' structure_slug=structure.slug %}">
<svg class="icon icon-xs">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use>
</svg>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

<div class="pb-4 clearfix">
<div class="pull-left d-none d-md-block">
<a role="button" class="btn btn-outline-{% if ticket_non_gestiti %}warning{% else %}secondary{% endif %}" href="{% url 'uni_ticket:user_unassigned_ticket' %}">
{% trans 'Aperte' %}
<a role="button" class="btn btn-outline-secondary" href="{% url 'uni_ticket:user_unassigned_ticket' %}">
<span class="badge badge-light">{{ ticket_non_gestiti }}</span> {% trans 'Aperte' %}
</a>
<a role="button" class="btn btn-outline-{% if ticket_aperti %}warning{% else %}secondary{% endif %}" href="{% url 'uni_ticket:user_opened_ticket' %}">
{% trans 'Assegnate' %}
<a role="button" class="btn btn-outline-secondary" href="{% url 'uni_ticket:user_opened_ticket' %}">
<span class="badge badge-light">{{ ticket_aperti }}</span> {% trans 'Assegnate' %}
</a>
<a role="button" class="btn btn-outline-secondary" href="{% url 'uni_ticket:user_closed_ticket' %}">
{% trans 'Chiuse' %}
</a>
<a role="button" class="btn btn-outline-{% if ticket_messages %}warning{% else %}secondary{% endif %}" href="{% url 'uni_ticket:messages' %}">
<svg class="icon icon-xs">
<a role="button" class="btn btn-outline-secondary" href="{% url 'uni_ticket:messages' %}">
<svg class="icon icon-xs {% if ticket_messages > 0 %}icon-warning{% endif %}">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use>
</svg>
{% trans 'Messaggi' %}
Expand All @@ -36,13 +36,19 @@
<ul>
<li>
<a href="{% url 'uni_ticket:user_unassigned_ticket' %}">
<svg class="icon {% if ticket_non_gestiti %}icon-warning{% endif %}"><use xlink:href="{% static 'svg/sprite.svg' %}#it-warning-circle"></use></svg>
{% if ticket_non_gestiti > 0 %}
<div class="badge-wrapper"><span class="toolbar-badge badge-primary">{{ ticket_non_gestiti }}</span></div>
{% endif %}
<svg class="icon"><use xlink:href="{% static 'svg/sprite.svg' %}#it-warning-circle"></use></svg>
<span class="toolbar-label">{% trans 'Aperte' %}</span></span>
</a>
</li>
<li>
<a href="{% url 'uni_ticket:user_opened_ticket' %}">
<svg class="icon {% if ticket_aperti %}icon-warning{% endif %}"><use xlink:href="{% static 'svg/sprite.svg' %}#it-clock"></use></svg>
{% if ticket_aperti > 0 %}
<div class="badge-wrapper"><span class="toolbar-badge">{{ ticket_aperti }}</span></div>
{% endif %}
<svg class="icon"><use xlink:href="{% static 'svg/sprite.svg' %}#it-clock"></use></svg>
<span class="toolbar-label">{% trans 'Assegnate' %}</span>
</a>
</li>
Expand All @@ -54,7 +60,7 @@
</li>
<li>
<a href="{% url 'uni_ticket:messages' %}">
<svg class="icon {% if ticket_messages %}icon-warning{% endif %}"><use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use></svg>
<svg class="icon {% if ticket_messages > 0 %}icon-warning{% endif %}"><use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use></svg>
<span class="toolbar-label">{% trans 'Messaggi' %}</span></span>
</a>
</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ <h5 class="modal-title">

{% if ticket_taken %}
<a role="button" href="{% url 'uni_ticket:ticket_message' ticket_id=ticket.code %}"
class="btn btn-outline-{% if unread_messages > 0 %}warning{% else %}secondary{% endif %}">
class="btn btn-outline-secondary">
{% get_unread_messages ticket=ticket as unread_messages %}
<svg class="icon icon-xs">
<svg class="icon icon-xs {% if unread_messages > 0 %}icon-warning{% endif %}">
<use xlink:href="{% static 'svg/sprite.svg' %}#it-comment"></use>
</svg> {% trans "Messaggi" %}
</a>
Expand Down

0 comments on commit a3cf363

Please sign in to comment.