From d7385da0df7c513c8dae01fe5a81e7421ebebcb5 Mon Sep 17 00:00:00 2001 From: David McDonald Date: Mon, 23 Mar 2020 11:04:03 +0000 Subject: [PATCH] Require email address for all support tickets We are seeing little benefit of allowing users to not put in their email address. This will mean that you must provide it for feedback, not just problems with the site. There could maybe be some more refactoring of the support templates as this is now very similar to the report a problem page but this is a quick fix so haven't gone too in depth. --- app/main/forms.py | 2 +- .../support/ask-question-give-feedback.html | 2 -- tests/app/main/views/test_feedback.py | 32 ++++--------------- 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 84017130a..bbec39080 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -894,7 +894,7 @@ class SupportType(StripWhitespaceForm): class Feedback(StripWhitespaceForm): name = StringField('Name') - email_address = email_address(label='Email address', gov_user=False, required=False) + email_address = email_address(label='Email address', gov_user=False, required=True) feedback = TextAreaField('Your message', validators=[DataRequired(message="Cannot be empty")]) diff --git a/app/templates/views/support/ask-question-give-feedback.html b/app/templates/views/support/ask-question-give-feedback.html index 3a236dd40..77e9ec8f9 100644 --- a/app/templates/views/support/ask-question-give-feedback.html +++ b/app/templates/views/support/ask-question-give-feedback.html @@ -19,8 +19,6 @@ {% call form_wrapper() %} {{ textbox(form.feedback, width='1-1', hint='', rows=10, autosize=True) }} {% if not current_user.is_authenticated %} -

Do you want a reply?

-

Leave your details below if you’d like a response.

{{ textbox(form.name, width='1-1') }} {{ textbox(form.email_address, width='1-1') }} {% else %} diff --git a/tests/app/main/views/test_feedback.py b/tests/app/main/views/test_feedback.py index 12fd61ded..684fc2b12 100644 --- a/tests/app/main/views/test_feedback.py +++ b/tests/app/main/views/test_feedback.py @@ -204,34 +204,15 @@ def test_passes_user_details_through_flow( {'feedback': 'blah', 'name': 'Fred'}, {'feedback': 'blah'}, ]) -@pytest.mark.parametrize('ticket_type, expected_response, expected_redirect, expected_error', [ - ( - PROBLEM_TICKET_TYPE, - 200, - lambda: None, - element.Tag, - ), - ( - QUESTION_TICKET_TYPE, - 302, - partial( - url_for, - '.thanks', - email_address_provided=False, - out_of_hours_emergency=False, - _external=True, - ), - type(None), - ), +@pytest.mark.parametrize('ticket_type', [ + PROBLEM_TICKET_TYPE, + QUESTION_TICKET_TYPE, ]) -def test_email_address_required_for_problems( +def test_email_address_required_for_problems_and_questions( client_request, mocker, data, ticket_type, - expected_response, - expected_redirect, - expected_error ): mocker.patch('app.main.views.feedback.zendesk_client') client_request.logout() @@ -239,10 +220,9 @@ def test_email_address_required_for_problems( 'main.feedback', ticket_type=ticket_type, _data=data, - _expected_status=expected_response, - _expected_redirect=expected_redirect(), + _expected_status=200 ) - assert isinstance(page.find('span', {'class': 'error-message'}), expected_error) + assert isinstance(page.find('span', {'class': 'error-message'}), element.Tag) @freeze_time('2016-12-12 12:00:00.000000')