From d9e6d9515d8fbccc3ab197f13eb63f6964dc94e8 Mon Sep 17 00:00:00 2001 From: bhargav1002 Date: Sun, 8 Jun 2025 17:30:19 +0530 Subject: [PATCH] Add follow-up creation and change tracking on ticket hold status --- helpdesk/views/staff.py | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 63f9ea9d..6e763808 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -71,6 +71,7 @@ from helpdesk.models import ( SavedSearch, Ticket, TicketCC, + TicketChange, TicketCustomFieldValue, TicketDependency, UserSettings, @@ -89,6 +90,7 @@ import re from rest_framework import status from rest_framework.decorators import api_view import typing +from django.utils.timezone import now if helpdesk_settings.HELPDESK_KB_ENABLED: @@ -1380,21 +1382,28 @@ def hold_ticket(request, ticket_id, unhold=False): if unhold: ticket.on_hold = False - title = _("Ticket taken off hold") + followup_title = _("Ticket taken off hold") else: ticket.on_hold = True - title = _("Ticket placed on hold") - - f = update_ticket( - user=request.user, - ticket=ticket, - title=title, - public=True, - ) - f.save() + followup_title = _("Ticket placed on hold") ticket.save() + followup = FollowUp.objects.create( + ticket=ticket, + title=followup_title, + date=now(), + public=True, + user=request.user, + ) + + TicketChange.objects.create( + followup=followup, + field=_("On Hold"), + old_value=str(not ticket.on_hold), + new_value=str(ticket.on_hold), + ) + return HttpResponseRedirect(ticket.get_absolute_url())