From 8fffae343ca6af8fb421fc1440bec3e1fea9107b Mon Sep 17 00:00:00 2001 From: Sam Splunks <72095718+samsplunks@users.noreply.github.com> Date: Tue, 16 Apr 2024 07:58:33 +0000 Subject: [PATCH] Update TicketChange creation code --- helpdesk/update_ticket.py | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/helpdesk/update_ticket.py b/helpdesk/update_ticket.py index deca0b40..f10a33d5 100644 --- a/helpdesk/update_ticket.py +++ b/helpdesk/update_ticket.py @@ -268,41 +268,33 @@ def update_ticket( files = process_attachments(f, files) if files else [] if ticket_title and ticket_title != ticket.title: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Title'), old_value=ticket.title, new_value=ticket_title, ) - c.save() ticket.title = ticket_title if new_status != old_status: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Status'), old_value=old_status_str, new_value=ticket.get_status_display(), ) - c.save() if ticket.assigned_to != old_owner: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Owner'), old_value=old_owner, new_value=ticket.assigned_to, ) - c.save() if priority != ticket.priority: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Priority'), old_value=ticket.priority, new_value=priority, ) - c.save() ticket.priority = priority if queue != ticket.queue.id: @@ -314,13 +306,11 @@ def update_ticket( ticket.queue_id = queue if due_date != ticket.due_date: - c = TicketChange( - followup=f, + c = f.ticketchange_set.create( field=_('Due on'), old_value=ticket.due_date, new_value=due_date, ) - c.save() ticket.due_date = due_date for checklist in ticket.checklists.all():