From 1a94137ff63070ad61ac7f42da8841fb8dcd4d57 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Wed, 27 Feb 2019 13:02:37 +0000 Subject: [PATCH] Add latest content From: https://docs.google.com/document/d/1aykf1MjJH5y21Bz1ht6WJncb9cKu0fsPlac3-bkMPe8/edit --- app/main/forms.py | 14 +++++++-- .../service-settings/estimate-usage.html | 13 ++++----- .../service-settings/request-to-go-live.html | 2 +- tests/app/main/views/test_service_settings.py | 29 +++++++++---------- 4 files changed, 33 insertions(+), 25 deletions(-) diff --git a/app/main/forms.py b/app/main/forms.py index 98a064fc2..556bf0dca 100644 --- a/app/main/forms.py +++ b/app/main/forms.py @@ -177,6 +177,10 @@ class ForgivingIntegerField(StringField): POSTGRES_MAX_INT = 2147483647 + def __init__(self, label=None, things='items', **kwargs): + self.things = things + super().__init__(label, **kwargs) + def process_formdata(self, valuelist): if valuelist: @@ -199,9 +203,12 @@ class ForgivingIntegerField(StringField): error = None try: if int(self.data) > self.POSTGRES_MAX_INT: - error = 'Must be less than {:,.0f}'.format(self.POSTGRES_MAX_INT) + error = 'Number of {} must be {:,.0f} or less'.format( + self.things, + self.POSTGRES_MAX_INT, + ) except ValueError: - error = 'Must be a whole number' + error = 'Number of {} must be in the correct format'.format(self.things) if error: raise ValidationError(error) @@ -649,12 +656,15 @@ class EstimateUsageForm(StripWhitespaceForm): volume_email = ForgivingIntegerField( 'How many emails do you expect to send in the next year?', + things='emails', ) volume_sms = ForgivingIntegerField( 'How many text messages do you expect to send in the next year?', + things='text messages', ) volume_letter = ForgivingIntegerField( 'How many letters do you expect to send in the next year?', + things='letters', ) consent_to_research = RadioField( 'Can we contact you when we’re doing user research?', diff --git a/app/templates/views/service-settings/estimate-usage.html b/app/templates/views/service-settings/estimate-usage.html index c22b7142f..71c618a74 100644 --- a/app/templates/views/service-settings/estimate-usage.html +++ b/app/templates/views/service-settings/estimate-usage.html @@ -6,7 +6,7 @@ {% from "components/textbox.html" import textbox %} {% block service_page_title %} - Estimate usage + Tell us how many messages you expect to send {% endblock %} {% block maincolumn_content %} @@ -15,18 +15,17 @@ {% if not form.at_least_one_volume_filled %} {% call banner_wrapper(type='dangerous') %}

- no things supplied + Enter the number of messages you expect to send in the next year

-

Tell us some things

{% endcall %} {% else %} -

Estimate usage

+

Tell us how many messages you expect to send

{% endif %} {% call form_wrapper() %}
- {{ textbox(form.volume_email, width='1-2', hint='For example, 1,000,000') }} - {{ textbox(form.volume_sms, width='1-2', hint='For example, 500,000') }} - {{ textbox(form.volume_letter, width='1-2', hint='For example, 5,000') }} + {{ textbox(form.volume_email, width='1-2', hint='For example, 50,000') }} + {{ textbox(form.volume_sms, width='1-2', hint='For example, 50,000') }} + {{ textbox(form.volume_letter, width='1-2', hint='For example, 50,000') }}
{{ radios(form.consent_to_research, hint='You don’t have to take part and you can unsubscribe at any time') }} {{ page_footer('Continue') }} 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 4f277e267..d9e25079a 100644 --- a/app/templates/views/service-settings/request-to-go-live.html +++ b/app/templates/views/service-settings/request-to-go-live.html @@ -14,7 +14,7 @@ {% call task_list_wrapper() %} {{ task_list_item( current_service.has_estimated_usage, - 'Estimate usage', + 'Tell us how many messages you expect to send', url_for('main.estimate_usage', service_id=current_service.id), ) }} {{ task_list_item( diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index fce926ea1..b9804fda3 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -516,11 +516,11 @@ def test_should_raise_duplicate_name_handled( @pytest.mark.parametrize('volumes, consent_to_research, expected_estimated_volumes_item', [ - ((0, 0, 0), None, 'Estimate usage Not completed'), - ((1, 0, 0), None, 'Estimate usage Not completed'), - ((1, 0, 0), False, 'Estimate usage Completed'), - ((1, 0, 0), True, 'Estimate usage Completed'), - ((9, 99, 999), True, 'Estimate usage Completed'), + ((0, 0, 0), None, 'Tell us how many messages you expect to send Not completed'), + ((1, 0, 0), None, 'Tell us how many messages you expect to send Not completed'), + ((1, 0, 0), False, 'Tell us how many messages you expect to send Completed'), + ((1, 0, 0), True, 'Tell us how many messages you expect to send Completed'), + ((9, 99, 999), True, 'Tell us how many messages you expect to send Completed'), ]) @pytest.mark.parametrize('count_of_users_with_manage_service, expected_user_checklist_item', [ (1, 'Add a team member who can manage settings, team and usage Not completed'), @@ -852,21 +852,21 @@ def test_should_show_estimate_volumes( page = client_request.get( 'main.estimate_usage', service_id=SERVICE_ONE_ID ) - assert page.h1.text == 'Estimate usage' + assert page.h1.text == 'Tell us how many messages you expect to send' for channel, label, value in ( ( 'email', - 'How many emails do you expect to send in the next year? For example, 1,000,000', + 'How many emails do you expect to send in the next year? For example, 50,000', displayed_volumes[0], ), ( 'sms', - 'How many text messages do you expect to send in the next year? For example, 500,000', + 'How many text messages do you expect to send in the next year? For example, 50,000', displayed_volumes[1], ), ( 'letter', - 'How many letters do you expect to send in the next year? For example, 5,000', + 'How many letters do you expect to send in the next year? For example, 50,000', displayed_volumes[2], ), ): @@ -921,8 +921,8 @@ def test_should_show_persist_estimated_volumes( }, 'label[for=volume_sms]', ( - 'How many text messages do you expect to send in the next year? For example, 500,000 ' - 'Must be less than 2,147,483,647' + 'How many text messages do you expect to send in the next year? For example, 50,000 ' + 'Number of text messages must be 2,147,483,647 or less' ) ), ( @@ -972,8 +972,7 @@ def test_should_error_if_all_volumes_zero( assert page.select('input[type=text]')[1]['value'] == '0' assert page.select('input[type=text]')[2]['value'] == '0,00 0' assert normalize_spaces(page.select_one('.banner-dangerous').text) == ( - 'no things supplied ' - 'Tell us some things' + 'Enter the number of messages you expect to send in the next year' ) assert mock_update_service.called is False @@ -1000,8 +999,8 @@ def test_should_not_default_to_zero_if_some_fields_dont_validate( page.select_one('label[for=volume_letter]').text ) == ( 'How many letters do you expect to send in the next year? ' - 'For example, 5,000 ' - 'Must be a whole number' + 'For example, 50,000 ' + 'Number of letters must be in the correct format' ) assert mock_update_service.called is False