mirror of
https://gitea.mueller.network/extern/django-helpdesk.git
synced 2024-11-21 23:43:11 +01:00
Save custom fields in a followup
This commit is contained in:
parent
8901086a80
commit
9ee0207c3c
@ -192,7 +192,27 @@ class EditTicketCustomFieldForm(EditTicketForm):
|
||||
super(EditTicketCustomFieldForm, self).__init__(*args, **kwargs)
|
||||
|
||||
del self.fields['merged_to']
|
||||
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
||||
# if form is saved in a ticket update, it is passed
|
||||
# a followup instance to trace custom fields changes
|
||||
if "followup" in kwargs:
|
||||
followup = kwargs.pop('followup', None)
|
||||
|
||||
for field, value in self.cleaned_data.items():
|
||||
if field.startswith('custom_'):
|
||||
if value != self.fields[field].initial:
|
||||
c = followup.ticketchange_set.create(
|
||||
field=field.replace('custom_', '', 1),
|
||||
old_value=self.fields[field].initial,
|
||||
new_value=value,
|
||||
)
|
||||
|
||||
super(EditTicketCustomFieldForm, self).save(*args, **kwargs)
|
||||
|
||||
|
||||
class Meta:
|
||||
model = Ticket
|
||||
exclude = ('title', 'queue', 'created', 'modified',
|
||||
|
@ -206,6 +206,7 @@ def update_ticket(
|
||||
due_date=None,
|
||||
new_checklists=None,
|
||||
message_id=None,
|
||||
customfields_form=None,
|
||||
):
|
||||
# We need to allow the 'ticket' and 'queue' contexts to be applied to the
|
||||
# comment.
|
||||
@ -312,7 +313,11 @@ def update_ticket(
|
||||
new_value=due_date,
|
||||
)
|
||||
ticket.due_date = due_date
|
||||
|
||||
|
||||
# save custom fields and ticket changes
|
||||
if customfields_form.is_valid():
|
||||
customfields_form.save(followup=f)
|
||||
|
||||
for checklist in ticket.checklists.all():
|
||||
if checklist.id not in new_checklists:
|
||||
continue
|
||||
|
@ -583,6 +583,10 @@ def update_ticket_view(request, ticket_id, public=False):
|
||||
priority = int(request.POST.get('priority', ticket.priority))
|
||||
queue = int(request.POST.get('queue', ticket.queue.id))
|
||||
|
||||
# custom fields
|
||||
customfields_form = EditTicketCustomFieldForm(request.POST or None,
|
||||
instance=ticket)
|
||||
|
||||
# Check if a change happened on checklists
|
||||
new_checklists = {}
|
||||
changes_in_checklists = False
|
||||
@ -609,6 +613,7 @@ def update_ticket_view(request, ticket_id, public=False):
|
||||
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),
|
||||
not customfields_form.has_changed(),
|
||||
])
|
||||
if no_changes:
|
||||
return return_to_ticket(request.user, helpdesk_settings, ticket)
|
||||
@ -627,6 +632,7 @@ def update_ticket_view(request, ticket_id, public=False):
|
||||
time_spent = get_time_spent_from_request(request),
|
||||
due_date = get_due_date_from_request_or_ticket(request, ticket),
|
||||
new_checklists = new_checklists,
|
||||
customfields_form = customfields_form,
|
||||
)
|
||||
|
||||
return return_to_ticket(request.user, helpdesk_settings, ticket)
|
||||
|
Loading…
Reference in New Issue
Block a user