Update TicketChange creation code

This commit is contained in:
Sam Splunks 2024-04-16 07:58:33 +00:00
parent 9f7c18e507
commit 8fffae343c

View File

@ -268,41 +268,33 @@ def update_ticket(
files = process_attachments(f, files) if files else [] files = process_attachments(f, files) if files else []
if ticket_title and ticket_title != ticket.title: if ticket_title and ticket_title != ticket.title:
c = TicketChange( c = f.ticketchange_set.create(
followup=f,
field=_('Title'), field=_('Title'),
old_value=ticket.title, old_value=ticket.title,
new_value=ticket_title, new_value=ticket_title,
) )
c.save()
ticket.title = ticket_title ticket.title = ticket_title
if new_status != old_status: if new_status != old_status:
c = TicketChange( c = f.ticketchange_set.create(
followup=f,
field=_('Status'), field=_('Status'),
old_value=old_status_str, old_value=old_status_str,
new_value=ticket.get_status_display(), new_value=ticket.get_status_display(),
) )
c.save()
if ticket.assigned_to != old_owner: if ticket.assigned_to != old_owner:
c = TicketChange( c = f.ticketchange_set.create(
followup=f,
field=_('Owner'), field=_('Owner'),
old_value=old_owner, old_value=old_owner,
new_value=ticket.assigned_to, new_value=ticket.assigned_to,
) )
c.save()
if priority != ticket.priority: if priority != ticket.priority:
c = TicketChange( c = f.ticketchange_set.create(
followup=f,
field=_('Priority'), field=_('Priority'),
old_value=ticket.priority, old_value=ticket.priority,
new_value=priority, new_value=priority,
) )
c.save()
ticket.priority = priority ticket.priority = priority
if queue != ticket.queue.id: if queue != ticket.queue.id:
@ -314,13 +306,11 @@ def update_ticket(
ticket.queue_id = queue ticket.queue_id = queue
if due_date != ticket.due_date: if due_date != ticket.due_date:
c = TicketChange( c = f.ticketchange_set.create(
followup=f,
field=_('Due on'), field=_('Due on'),
old_value=ticket.due_date, old_value=ticket.due_date,
new_value=due_date, new_value=due_date,
) )
c.save()
ticket.due_date = due_date ticket.due_date = due_date
for checklist in ticket.checklists.all(): for checklist in ticket.checklists.all():