Allow to track queue change in follow-ups

This commit is contained in:
Sam Splunks 2024-04-08 12:33:23 +00:00
parent c9ca97516a
commit 42be32b17b
3 changed files with 21 additions and 0 deletions

View File

@ -150,6 +150,9 @@
<dt><label for='id_priority'>{% trans "Priority" %}</label></dt> <dt><label for='id_priority'>{% trans "Priority" %}</label></dt>
<dd><select id='id_priority' name='priority'>{% for p in priorities %}{% if p.0 == ticket.priority %}<option value='{{ p.0 }}' selected='selected'>{{ p.1 }}</option>{% else %}<option value='{{ p.0 }}'>{{ p.1 }}</option>{% endif %}{% endfor %}</select></dd> <dd><select id='id_priority' name='priority'>{% for p in priorities %}{% if p.0 == ticket.priority %}<option value='{{ p.0 }}' selected='selected'>{{ p.1 }}</option>{% else %}<option value='{{ p.0 }}'>{{ p.1 }}</option>{% endif %}{% endfor %}</select></dd>
<dt><label for='id_queue'>{% trans "Queue" %}</label></dt>
<dd><select id='id_queue' name='queue'>{% for q in queues %}{% if q.0 == ticket.queue.id %}<option value='{{ q.0 }}' selected='selected'>{{ q.1 }}</option>{% else %}<option value='{{ q.0 }}'>{{ q.1 }}</option>{% endif %}{% endfor %}</select></dd>
<dt><label for='id_due_date'>{% trans "Due on" %}</label></dt> <dt><label for='id_due_date'>{% trans "Due on" %}</label></dt>
<dd>{{ form.due_date }}</dd> <dd>{{ form.due_date }}</dd>

View File

@ -12,6 +12,7 @@ from helpdesk.decorators import (
is_helpdesk_staff, is_helpdesk_staff,
) )
from helpdesk.models import ( from helpdesk.models import (
Queue,
FollowUp, FollowUp,
Ticket, Ticket,
TicketCC, TicketCC,
@ -200,6 +201,7 @@ def update_ticket(
owner=-1, owner=-1,
ticket_title=None, ticket_title=None,
priority=-1, priority=-1,
queue=-1,
new_status=None, new_status=None,
time_spent=None, time_spent=None,
due_date=None, due_date=None,
@ -213,6 +215,8 @@ def update_ticket(
title = ticket.title title = ticket.title
if priority == -1: if priority == -1:
priority = ticket.priority priority = ticket.priority
if queue == -1:
queue = ticket.queue.id
if new_status is None: if new_status is None:
new_status = ticket.status new_status = ticket.status
if new_checklists is None: if new_checklists is None:
@ -302,6 +306,16 @@ def update_ticket(
c.save() c.save()
ticket.priority = priority ticket.priority = priority
if queue != ticket.queue.id:
c = TicketChange(
followup=f,
field=_('Queue'),
old_value=ticket.queue.id,
new_value=queue,
)
c.save()
ticket.queue.id = queue
if due_date != ticket.due_date: if due_date != ticket.due_date:
c = TicketChange( c = TicketChange(
followup=f, followup=f,

View File

@ -428,6 +428,7 @@ def view_ticket(request, ticket_id):
'form': form, 'form': form,
'active_users': users, 'active_users': users,
'priorities': Ticket.PRIORITY_CHOICES, 'priorities': Ticket.PRIORITY_CHOICES,
'queues': queue_choices,
'preset_replies': PreSetReply.objects.filter( 'preset_replies': PreSetReply.objects.filter(
Q(queues=ticket.queue) | Q(queues__isnull=True)), Q(queues=ticket.queue) | Q(queues__isnull=True)),
'ticketcc_string': ticketcc_string, 'ticketcc_string': ticketcc_string,
@ -566,6 +567,7 @@ def update_ticket_view(request, ticket_id, public=False):
title = request.POST.get('title', '') title = request.POST.get('title', '')
owner = int(request.POST.get('owner', -1)) owner = int(request.POST.get('owner', -1))
priority = int(request.POST.get('priority', ticket.priority)) priority = int(request.POST.get('priority', ticket.priority))
queue = int(request.POST.get('queue', ticket.queue.id))
# Check if a change happened on checklists # Check if a change happened on checklists
new_checklists = {} new_checklists = {}
@ -589,6 +591,7 @@ def update_ticket_view(request, ticket_id, public=False):
new_status == ticket.status, new_status == ticket.status,
title == ticket.title, title == ticket.title,
priority == int(ticket.priority), priority == int(ticket.priority),
queue == int(ticket.queue.id),
due_date == ticket.due_date, due_date == ticket.due_date,
(owner == -1) or (not owner and not ticket.assigned_to) or (owner == -1) or (not owner and not ticket.assigned_to) or
(owner and User.objects.get(id=owner) == ticket.assigned_to), (owner and User.objects.get(id=owner) == ticket.assigned_to),
@ -605,6 +608,7 @@ def update_ticket_view(request, ticket_id, public=False):
public = request.POST.get('public', False), public = request.POST.get('public', False),
owner = int(request.POST.get('owner', -1)), owner = int(request.POST.get('owner', -1)),
priority = int(request.POST.get('priority', -1)), priority = int(request.POST.get('priority', -1)),
queue = int(request.POST.get('queue', -1)),
new_status = new_status, new_status = new_status,
time_spent = get_time_spent_from_request(request), time_spent = get_time_spent_from_request(request),
due_date = get_due_date_from_request_or_ticket(request, ticket), due_date = get_due_date_from_request_or_ticket(request, ticket),