From cd019d11289af56aefaad9a871a5d07340bbdcd4 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Tue, 14 Jan 2020 17:41:55 +0100 Subject: [PATCH] Improvements to iframe workflow --- helpdesk/templates/helpdesk/public_create_ticket_base.html | 2 +- helpdesk/templates/helpdesk/success_iframe.html | 4 ++++ helpdesk/urls.py | 4 ++++ helpdesk/views/public.py | 7 +++++++ 4 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 helpdesk/templates/helpdesk/success_iframe.html diff --git a/helpdesk/templates/helpdesk/public_create_ticket_base.html b/helpdesk/templates/helpdesk/public_create_ticket_base.html index d82fd466..82cf375b 100644 --- a/helpdesk/templates/helpdesk/public_create_ticket_base.html +++ b/helpdesk/templates/helpdesk/public_create_ticket_base.html @@ -4,7 +4,7 @@ {% if helpdesk_settings.HELPDESK_SUBMIT_A_TICKET_PUBLIC %}

{% trans "Unless otherwise stated, all fields are required." %} {% trans "Please provide as descriptive a title and description as possible." %}

-
+ {{ form|bootstrap4form }} {% csrf_token %}
diff --git a/helpdesk/templates/helpdesk/success_iframe.html b/helpdesk/templates/helpdesk/success_iframe.html new file mode 100644 index 00000000..d2d28a2a --- /dev/null +++ b/helpdesk/templates/helpdesk/success_iframe.html @@ -0,0 +1,4 @@ +{% load i18n %} +

+{% trans "Ticket submitted successfully! We will reply via email as soon as we get the chance." %} +

diff --git a/helpdesk/urls.py b/helpdesk/urls.py index 59f27bcc..3ad3216b 100644 --- a/helpdesk/urls.py +++ b/helpdesk/urls.py @@ -171,6 +171,10 @@ urlpatterns += [ public.CreateTicketIframeView.as_view(), name='submit_iframe'), + url(r'^tickets/success_iframe/$', # Ticket was submitted successfully + public.SuccessIframeView.as_view(), + name='success_iframe'), + url(r'^view/$', public.view_ticket, name='public_view'), diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index 810f75e0..50b7038d 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -107,6 +107,13 @@ class CreateTicketIframeView(BaseCreateTicketView): def dispatch(self, *args, **kwargs): return super().dispatch(*args, **kwargs) + def form_valid(self, form): + if super().form_valid(form).status_code == 302: + return HttpResponseRedirect(reverse('helpdesk:success_iframe')) + + +class SuccessIframeView(TemplateView): + template_name = 'helpdesk/success_iframe.html' class CreateTicketView(BaseCreateTicketView):