From fbae21828117ea6834c6f17e3727d52aa832e4c2 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Thu, 12 Dec 2019 17:17:17 +0100 Subject: [PATCH] Add ability to autoset custom fields in public ticket form --- helpdesk/views/public.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index 1bade147..5dca261a 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -21,7 +21,7 @@ from helpdesk.decorators import protect_view, is_helpdesk_staff import helpdesk.views.staff as staff from helpdesk.forms import PublicTicketForm from helpdesk.lib import text_is_spam -from helpdesk.models import Ticket, Queue, UserSettings, KBCategory +from helpdesk.models import CustomField, Ticket, Queue, UserSettings, KBCategory def create_ticket(request, *args, **kwargs): @@ -83,6 +83,8 @@ class BaseCreateTicketView(FormView): initial_data['submitter_email'] = request.user.email query_param_fields = ['submitter_email', 'title', 'body'] + custom_fields = ["custom_%s" % f.name for f in CustomField.objects.filter(staff_only=False)] + query_param_fields += custom_fields for qpf in query_param_fields: initial_data[qpf] = request.GET.get(qpf, initial_data.get(qpf, "")) return initial_data