From aadfe08504f1d0a7dba391b8ef876fa1a0335db3 Mon Sep 17 00:00:00 2001 From: Timothy Hobbs Date: Thu, 12 Dec 2019 15:22:12 +0100 Subject: [PATCH] Add iframe supporting view for submitting tickets --- helpdesk/templates/helpdesk/base-head.html | 74 +++++++++++++++++++ helpdesk/templates/helpdesk/base.html | 64 +--------------- helpdesk/templates/helpdesk/public_base.html | 38 +--------- .../helpdesk/public_create_ticket.html | 19 ++--- .../helpdesk/public_create_ticket_base.html | 14 ++++ .../helpdesk/public_create_ticket_iframe.html | 11 +++ helpdesk/urls.py | 4 + helpdesk/views/public.py | 11 ++- 8 files changed, 121 insertions(+), 114 deletions(-) create mode 100644 helpdesk/templates/helpdesk/base-head.html create mode 100644 helpdesk/templates/helpdesk/public_create_ticket_base.html create mode 100644 helpdesk/templates/helpdesk/public_create_ticket_iframe.html diff --git a/helpdesk/templates/helpdesk/base-head.html b/helpdesk/templates/helpdesk/base-head.html new file mode 100644 index 00000000..872afdfa --- /dev/null +++ b/helpdesk/templates/helpdesk/base-head.html @@ -0,0 +1,74 @@ +{% load i18n %} +{% load saved_queries %} +{% load load_helpdesk_settings %} +{% load static from staticfiles %} +{% with request|load_helpdesk_settings as helpdesk_settings %} +{% with user|saved_queries as user_saved_queries_ %} + + + + + + + +{% block helpdesk_title %}Helpdesk{% endblock %} :: {% trans "Powered by django-helpdesk" %} + + + +{% if helpdesk_settings.HELPDESK_USE_CDN %} + +{% else %} + +{% endif %} + + + + + + + + + + + +{% if helpdesk_settings.HELPDESK_USE_CDN %} + +{% else %} + +{% endif %} + + + + + +{% if user.id %} + + + + + + + + +{% endif %} +{% endwith %} +{% endwith %} diff --git a/helpdesk/templates/helpdesk/base.html b/helpdesk/templates/helpdesk/base.html index 7342d08f..751ca263 100644 --- a/helpdesk/templates/helpdesk/base.html +++ b/helpdesk/templates/helpdesk/base.html @@ -9,69 +9,7 @@ - - - - - - - {% block helpdesk_title %}Helpdesk{% endblock %} :: {% trans "Powered by django-helpdesk" %} - - - {% if helpdesk_settings.HELPDESK_USE_CDN %} - - {% else %} - - {% endif %} - - - - - - - - - - - - {% if helpdesk_settings.HELPDESK_USE_CDN %} - - {% else %} - - {% endif %} - - - - - - - - - - - - - - + {% include 'helpdesk/base-head.html' %} {% block helpdesk_head %}{% endblock %} diff --git a/helpdesk/templates/helpdesk/public_base.html b/helpdesk/templates/helpdesk/public_base.html index 24a2157f..b0aaa679 100644 --- a/helpdesk/templates/helpdesk/public_base.html +++ b/helpdesk/templates/helpdesk/public_base.html @@ -1,47 +1,13 @@ {% load i18n %} -{% load load_helpdesk_settings %} {% load static from staticfiles %} +{% load load_helpdesk_settings %} {% with request|load_helpdesk_settings as helpdesk_settings %} - - - - - - - {% block helpdesk_title %}{% trans 'Helpdesk' %}{% endblock %} :: {% trans "Powered by django-helpdesk" %} - - - {% if helpdesk_settings.HELPDESK_USE_CDN %} - - {% else %} - - {% endif %} - - - - - - - - - - - - - - - - - - + {% include 'helpdesk/base-head.html' %} {% block helpdesk_head %}{% endblock %} diff --git a/helpdesk/templates/helpdesk/public_create_ticket.html b/helpdesk/templates/helpdesk/public_create_ticket.html index a902e344..fca1d845 100644 --- a/helpdesk/templates/helpdesk/public_create_ticket.html +++ b/helpdesk/templates/helpdesk/public_create_ticket.html @@ -1,5 +1,5 @@ {% extends "helpdesk/public_base.html" %} -{% load i18n bootstrap4form %} +{% load i18n %} {% block helpdesk_title %}{% trans "Create Ticket" %}{% endblock %} @@ -11,20 +11,13 @@ {% endblock %} {% block helpdesk_body %} -{% if helpdesk_settings.HELPDESK_SUBMIT_A_TICKET_PUBLIC %} -
-
+
+
{% trans "Submit a Ticket" %}
-

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

-
- {{ form|bootstrap4form }} - - {% csrf_token %}
+ {% include 'helpdesk/public_create_ticket_base.html' %}
-
-{% else %} -

{% trans "Public ticket submission is disabled. Please contact the administrator for assistance." %}

-{% endif %} +
+ {% endblock %} diff --git a/helpdesk/templates/helpdesk/public_create_ticket_base.html b/helpdesk/templates/helpdesk/public_create_ticket_base.html new file mode 100644 index 00000000..d82fd466 --- /dev/null +++ b/helpdesk/templates/helpdesk/public_create_ticket_base.html @@ -0,0 +1,14 @@ +{% load i18n bootstrap4form %} +{% load load_helpdesk_settings %} +{% with request|load_helpdesk_settings as helpdesk_settings %} + +{% 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 %}
+{% else %} +

{% trans "Public ticket submission is disabled. Please contact the administrator for assistance." %}

+{% endif %} +{% endwith %} diff --git a/helpdesk/templates/helpdesk/public_create_ticket_iframe.html b/helpdesk/templates/helpdesk/public_create_ticket_iframe.html new file mode 100644 index 00000000..a20f0722 --- /dev/null +++ b/helpdesk/templates/helpdesk/public_create_ticket_iframe.html @@ -0,0 +1,11 @@ +{% load i18n %} +{% load saved_queries %} + + {% include 'helpdesk/base-head.html' %} + + + + {% block helpdesk_body %} + {% include 'helpdesk/public_create_ticket_base.html' %} + {% endblock %} + diff --git a/helpdesk/urls.py b/helpdesk/urls.py index 059b088d..c0d3223f 100644 --- a/helpdesk/urls.py +++ b/helpdesk/urls.py @@ -167,6 +167,10 @@ urlpatterns += [ public.create_ticket, name='submit'), + url(r'^tickets/submit_iframe/$', + public.CreateTicketIframeView.as_view(), + name='submit_iframe'), + url(r'^view/$', public.view_ticket, name='public_view'), diff --git a/helpdesk/views/public.py b/helpdesk/views/public.py index eebf9c41..1bade147 100644 --- a/helpdesk/views/public.py +++ b/helpdesk/views/public.py @@ -31,8 +31,7 @@ def create_ticket(request, *args, **kwargs): return CreateTicketView.as_view()(request, *args, **kwargs) -class CreateTicketView(FormView): - template_name = 'helpdesk/public_create_ticket.html' +class BaseCreateTicketView(FormView): form_class = PublicTicketForm def dispatch(self, *args, **kwargs): @@ -115,6 +114,14 @@ class CreateTicketView(FormView): request = self.request +class CreateTicketIframeView(BaseCreateTicketView): + template_name = 'helpdesk/public_create_ticket_iframe.html' + + +class CreateTicketView(BaseCreateTicketView): + template_name = 'helpdesk/public_create_ticket.html' + + class Homepage(CreateTicketView): template_name = 'helpdesk/public_homepage.html'