From d832a9107cc2ccdfc286d809cf366fcb3dc5f7c4 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 31 Oct 2016 15:05:22 +0000 Subject: [PATCH] Use radio buttons not textboxes for multi-choice No need to make people type when they can click, and gives us consistent data. --- app/main/forms.py | 18 ++++++++++++++---- .../service-settings/request-to-go-live.html | 5 +++-- tests/app/main/views/test_service_settings.py | 12 ++++++------ 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 650f72891..3f4970c97 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -350,9 +350,14 @@ class Feedback(Form): class RequestToGoLiveForm(Form): - channel = StringField( + channel = RadioField( 'Are you sending emails or text messages or both?', - validators=[DataRequired(message='Can’t be empty')] + choices=[ + ('emails', 'Emails'), + ('text messages', 'Text messages'), + ('emails and text messages', 'Both') + ], + validators=[DataRequired()] ) start_date = StringField( 'When will you be ready to start sending messages?', @@ -366,10 +371,15 @@ class RequestToGoLiveForm(Form): 'Will the number of messages a month increase and when will that start? Give an estimate.', validators=[DataRequired(message='Can’t be empty')] ) - upload_or_api = StringField( + upload_or_api = RadioField( 'Are you uploading a list of contacts that you’re sending your message to, ' + 'or are you integrating your system with ours?', - validators=[DataRequired(message='Can’t be empty')] + choices=[ + ('File upload', 'Upload a spreadsheet of recipients'), + ('API', 'Integrate with the GOV.UK Notify API'), + ('API and file upload', 'Both') + ], + validators=[DataRequired()] ) diff --git a/app/templates/views/service-settings/request-to-go-live.html b/app/templates/views/service-settings/request-to-go-live.html index d64bc2fa5..ac7826ba3 100644 --- a/app/templates/views/service-settings/request-to-go-live.html +++ b/app/templates/views/service-settings/request-to-go-live.html @@ -1,5 +1,6 @@ {% extends "withnav_template.html" %} {% from "components/textbox.html" import textbox %} +{% from "components/radios.html" import radios %} {% from "components/page-footer.html" import page_footer %} {% from "components/banner.html" import banner_wrapper %} @@ -39,11 +40,11 @@
- {{ textbox(form.channel, width='1-1') }} + {{ radios(form.channel) }} {{ textbox(form.start_date, width='1-1') }} {{ textbox(form.start_volume, width='1-1') }} {{ textbox(form.peak_volume, width='1-1') }} - {{ textbox(form.upload_or_api, width='1-1') }} + {{ radios(form.upload_or_api) }}

Once you’ve completed the tasks needed to set up, we’ll make your service live. We’ll do this within one working day. diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index cb26e0a9b..bef3de3fb 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -314,11 +314,11 @@ def test_should_redirect_after_request_to_go_live( response = client.post( url_for('main.service_request_to_go_live', service_id='6ce466d0-fd6a-11e5-82f5-e0accb9d11a6'), data={ - 'channel': 'Email', + 'channel': 'emails', 'start_date': '01/01/2017', 'start_volume': '100,000', 'peak_volume': '2,000,000', - 'upload_or_api': 'api' + 'upload_or_api': 'API' }, follow_redirects=True ) @@ -337,11 +337,11 @@ def test_should_redirect_after_request_to_go_live( ) returned_message = mock_post.call_args[1]['data']['message'] - assert 'Email' in returned_message + assert 'emails' in returned_message assert '01/01/2017' in returned_message assert '100,000' in returned_message assert '2,000,000' in returned_message - assert 'api' in returned_message + assert 'API' in returned_message page = BeautifulSoup(response.data.decode('utf-8'), 'html.parser') flash_banner = page.find('div', class_='banner-default').string.strip() @@ -376,11 +376,11 @@ def test_log_error_on_request_to_go_live( resp = client.post( url_for('main.service_request_to_go_live', service_id='6ce466d0-fd6a-11e5-82f5-e0accb9d11a6'), data={ - 'channel': 'channel', + 'channel': 'emails', 'start_date': 'start_date', 'start_volume': 'start_volume', 'peak_volume': 'peak_volume', - 'upload_or_api': 'upload_or_api' + 'upload_or_api': 'API' } ) mock_logger.assert_called_with(