From 197e98d891d09c05af5b3ae53e805f978a741a14 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 7 Jun 2022 13:44:58 +0100 Subject: [PATCH] Refactor support ticket into a template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the same thing we do for go live requests and branding requests. It’s easier to do templating logic in a templating language than in Python. --- app/main/views/feedback.py | 13 +++---------- app/templates/support-tickets/support-ticket.txt | 5 +++++ 2 files changed, 8 insertions(+), 10 deletions(-) create mode 100644 app/templates/support-tickets/support-ticket.txt diff --git a/app/main/views/feedback.py b/app/main/views/feedback.py index 16c00903c..f76f6e95e 100644 --- a/app/main/views/feedback.py +++ b/app/main/views/feedback.py @@ -114,17 +114,10 @@ def feedback(ticket_type): if form.validate_on_submit(): user_email = form.email_address.data user_name = form.name.data or None - if current_service: - service_string = 'Service: "{name}"\n{url}\n'.format( - name=current_service.name, - url=url_for('main.service_dashboard', service_id=current_service.id) - ) - else: - service_string = '' - feedback_msg = '{}\n{}'.format( - form.feedback.data, - service_string, + feedback_msg = render_template( + 'support-tickets/support-ticket.txt', + content=form.feedback.data, ) ticket = NotifySupportTicket( diff --git a/app/templates/support-tickets/support-ticket.txt b/app/templates/support-tickets/support-ticket.txt new file mode 100644 index 000000000..109699bab --- /dev/null +++ b/app/templates/support-tickets/support-ticket.txt @@ -0,0 +1,5 @@ +{{ content }} +{% if current_service -%} +Service: "{{ current_service.name }}" +{{ url_for('main.service_dashboard', service_id=current_service.id) }} +{% endif %}