From 42be32b17b0234b959dddd5958c1d3ec90a005f7 Mon Sep 17 00:00:00 2001
From: Sam Splunks <72095718+samsplunks@users.noreply.github.com>
Date: Mon, 8 Apr 2024 12:33:23 +0000
Subject: [PATCH] Allow to track queue change in follow-ups
---
helpdesk/templates/helpdesk/ticket.html | 3 +++
helpdesk/update_ticket.py | 14 ++++++++++++++
helpdesk/views/staff.py | 4 ++++
3 files changed, 21 insertions(+)
diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html
index b4eb61db..6efdb8e1 100644
--- a/helpdesk/templates/helpdesk/ticket.html
+++ b/helpdesk/templates/helpdesk/ticket.html
@@ -150,6 +150,9 @@
+
+
+
{{ form.due_date }}
diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py
index 711566ba..cd2542a3 100644
--- a/helpdesk/update_ticket.py
+++ b/helpdesk/update_ticket.py
@@ -12,6 +12,7 @@ from helpdesk.decorators import (
is_helpdesk_staff,
)
from helpdesk.models import (
+ Queue,
FollowUp,
Ticket,
TicketCC,
@@ -200,6 +201,7 @@ def update_ticket(
owner=-1,
ticket_title=None,
priority=-1,
+ queue=-1,
new_status=None,
time_spent=None,
due_date=None,
@@ -213,6 +215,8 @@ def update_ticket(
title = ticket.title
if priority == -1:
priority = ticket.priority
+ if queue == -1:
+ queue = ticket.queue.id
if new_status is None:
new_status = ticket.status
if new_checklists is None:
@@ -302,6 +306,16 @@ def update_ticket(
c.save()
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:
c = TicketChange(
followup=f,
diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py
index e1cdc967..8abb9e7b 100644
--- a/helpdesk/views/staff.py
+++ b/helpdesk/views/staff.py
@@ -428,6 +428,7 @@ def view_ticket(request, ticket_id):
'form': form,
'active_users': users,
'priorities': Ticket.PRIORITY_CHOICES,
+ 'queues': queue_choices,
'preset_replies': PreSetReply.objects.filter(
Q(queues=ticket.queue) | Q(queues__isnull=True)),
'ticketcc_string': ticketcc_string,
@@ -566,6 +567,7 @@ def update_ticket_view(request, ticket_id, public=False):
title = request.POST.get('title', '')
owner = int(request.POST.get('owner', -1))
priority = int(request.POST.get('priority', ticket.priority))
+ queue = int(request.POST.get('queue', ticket.queue.id))
# Check if a change happened on checklists
new_checklists = {}
@@ -589,6 +591,7 @@ def update_ticket_view(request, ticket_id, public=False):
new_status == ticket.status,
title == ticket.title,
priority == int(ticket.priority),
+ queue == int(ticket.queue.id),
due_date == ticket.due_date,
(owner == -1) or (not owner and not ticket.assigned_to) or
(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),
owner = int(request.POST.get('owner', -1)),
priority = int(request.POST.get('priority', -1)),
+ queue = int(request.POST.get('queue', -1)),
new_status = new_status,
time_spent = get_time_spent_from_request(request),
due_date = get_due_date_from_request_or_ticket(request, ticket),