From 197e98d891d09c05af5b3ae53e805f978a741a14 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 7 Jun 2022 13:44:58 +0100 Subject: [PATCH 1/2] 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 %} From b91babc67e5ea3b9a5e0d01a85dc75708ed486d4 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 7 Jun 2022 13:46:02 +0100 Subject: [PATCH 2/2] Fix relative URLs in support tickets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When we get a support ticket we put a link to the service at the end. As part of 8b7f2fbf041c182156cbdb4d3fbadc1c851e6653 we accidentally made these URLs relative, rather than absolute. This means they aren’t made into links by email clients or Zendesk. This commit fixes the links to include the domain again. --- app/templates/support-tickets/support-ticket.txt | 2 +- tests/app/main/views/test_feedback.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/templates/support-tickets/support-ticket.txt b/app/templates/support-tickets/support-ticket.txt index 109699bab..08fd2629d 100644 --- a/app/templates/support-tickets/support-ticket.txt +++ b/app/templates/support-tickets/support-ticket.txt @@ -1,5 +1,5 @@ {{ content }} {% if current_service -%} Service: "{{ current_service.name }}" -{{ url_for('main.service_dashboard', service_id=current_service.id) }} +{{ url_for('main.service_dashboard', service_id=current_service.id, _external=True) }} {% endif %} diff --git a/tests/app/main/views/test_feedback.py b/tests/app/main/views/test_feedback.py index 4606461d2..8f73087ca 100644 --- a/tests/app/main/views/test_feedback.py +++ b/tests/app/main/views/test_feedback.py @@ -237,6 +237,7 @@ def test_passes_user_details_through_flow( url_for( 'main.service_dashboard', service_id=SERVICE_ONE_ID, + _external=True, ), '' ])