diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 83a3de45..3b2c3c81 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -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: diff --git a/helpdesk/templates/helpdesk/ticket.html b/helpdesk/templates/helpdesk/ticket.html index ce7d61e4..dfa8c9ee 100644 --- a/helpdesk/templates/helpdesk/ticket.html +++ b/helpdesk/templates/helpdesk/ticket.html @@ -163,6 +163,10 @@ +
+
{{ customfields_form }}
+
+ {% if ticket.checklists.exists %} diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index f89b5d08..f98a666e 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -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, })