Display custom fields in Follow-up form

This commit is contained in:
Sam Splunks 2024-07-26 08:46:26 +00:00
parent 4adcc7f3d3
commit f8cccbcf0a
3 changed files with 30 additions and 0 deletions

View File

@ -180,6 +180,27 @@ class EditTicketForm(CustomFieldMixin, forms.ModelForm):
return super(EditTicketForm, self).save(*args, **kwargs)
class EditTicketCustomFieldForm(EditTicketForm):
"""
Uses the EditTicketForm logic to provide a form for Ticket custom fields.
"""
def __init__(self, *args, **kwargs):
"""
Add any custom fields that are defined to the form
"""
super(EditTicketCustomFieldForm, self).__init__(*args, **kwargs)
del self.fields['merged_to']
class Meta:
model = Ticket
exclude = ('title', 'queue', 'created', 'modified',
'submitter_email', 'assigned_to', 'status',
'on_hold', 'description', 'resolution', 'priority',
'due_date', 'last_escalation', 'secret_key', 'kbitem')
class EditFollowUpForm(forms.ModelForm):
class Meta:

View File

@ -163,6 +163,10 @@
</dl>
<dl>
<dt>{{ customfields_form }}</dt>
</dl>
</div>
{% if ticket.checklists.exists %}

View File

@ -46,6 +46,7 @@ from helpdesk.forms import (
CUSTOMFIELD_DATE_FORMAT,
EditFollowUpForm,
EditTicketForm,
EditTicketCustomFieldForm,
EmailIgnoreForm,
FormControlDeleteFormSet,
MultipleTicketSelectForm,
@ -430,6 +431,9 @@ def view_ticket(request, ticket_id):
default=2
)).order_by('rank')
# add custom fields to further details panel
customfields_form = EditTicketCustomFieldForm(None, instance=ticket)
return render(request, 'helpdesk/ticket.html', {
'ticket': ticket,
'dependencies': dependencies,
@ -443,6 +447,7 @@ def view_ticket(request, ticket_id):
'ticketcc_string': ticketcc_string,
'SHOW_SUBSCRIBE': show_subscribe,
'checklist_form': checklist_form,
'customfields_form': customfields_form,
})