diff --git a/app/__init__.py b/app/__init__.py index 2314647e4..c469b4a27 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -356,17 +356,32 @@ def format_notification_status_as_time(status, created, updated): }.get(status, updated) -def format_notification_status_as_field_status(status): +def format_notification_status_as_field_status(status, notification_type): return { - 'failed': 'error', - 'technical-failure': 'error', - 'temporary-failure': 'error', - 'permanent-failure': 'error', - 'delivered': None, - 'sent': None, - 'sending': 'default', - 'created': 'default' - }.get(status, 'error') + 'letter': { + 'failed': 'error', + 'technical-failure': 'error', + 'temporary-failure': 'error', + 'permanent-failure': 'error', + 'delivered': None, + 'sent': None, + 'sending': None, + 'created': None, + 'accepted': None, + } + }.get( + notification_type, + { + 'failed': 'error', + 'technical-failure': 'error', + 'temporary-failure': 'error', + 'permanent-failure': 'error', + 'delivered': None, + 'sent': None, + 'sending': 'default', + 'created': 'default' + } + ).get(status, 'error') def format_notification_status_as_url(status): diff --git a/app/main/views/service_settings.py b/app/main/views/service_settings.py index fd2479714..b472e5c67 100644 --- a/app/main/views/service_settings.py +++ b/app/main/views/service_settings.py @@ -163,7 +163,23 @@ def service_name_change_confirm(service_id): @login_required @user_has_permissions('manage_service') def request_to_go_live(service_id): - return render_template('views/service-settings/request-to-go-live.html') + return render_template( + 'views/service-settings/request-to-go-live.html', + has_team_members=( + user_api_client.get_count_of_users_with_permission( + service_id, 'manage_settings' + ) > 1 + ), + has_templates=( + service_api_client.count_service_templates(service_id) > 0 + ), + has_email_templates=( + service_api_client.count_service_templates(service_id, template_type='email') > 0 + ), + has_email_reply_to_address=bool( + service_api_client.get_reply_to_email_addresses(service_id) + ) + ) @main.route("/services//service-settings/submit-request-to-go-live", methods=['GET', 'POST']) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 380d595d0..49b554120 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -130,7 +130,10 @@ {% if not notification %} {% call field(align='right') %}{% endcall %} {% else %} - {% call field(status=notification.status|format_notification_status_as_field_status, align='right') %} + {% call field( + status=notification.status|format_notification_status_as_field_status(notification.notification_type), + align='right' + ) %} {% if notification.status in ['created', 'sending', 'delivered'] %}{% endif %} {% if notification.status|format_notification_status_as_url %} diff --git a/app/templates/components/tick-cross.html b/app/templates/components/tick-cross.html index 6467b38ca..f6fbc9ecf 100644 --- a/app/templates/components/tick-cross.html +++ b/app/templates/components/tick-cross.html @@ -1,15 +1,20 @@ -{% macro tick_cross(yes, label) %} +{% macro tick_cross(yes, label, truthy_hint='Can', falsey_hint='Can’t') %}
  • {% if yes %} - Can + {{ truthy_hint }} {{ label}} {% else %} - Can’t + {{ falsey_hint }} {{ label}} {% endif %}
  • {% endmacro %} + + +{% macro tick_cross_done_not_done(yes, label) %} + {{ tick_cross(yes, label, truthy_hint='Done: ', falsey_hint='Not done: ') }} +{% endmacro %} diff --git a/app/templates/partials/notifications/status.html b/app/templates/partials/notifications/status.html index 730eb6954..780445799 100644 --- a/app/templates/partials/notifications/status.html +++ b/app/templates/partials/notifications/status.html @@ -1,5 +1,5 @@
    -

    +

    {% if notification.status|format_notification_status_as_url %} {% endif %} diff --git a/app/templates/views/pricing.html b/app/templates/views/pricing.html index 6cdb834c4..1dc619705 100644 --- a/app/templates/views/pricing.html +++ b/app/templates/views/pricing.html @@ -27,7 +27,7 @@

    You have a free allowance of text messages each financial year. You’ll get:

    • 250,000 free text messages for central government services
    • -
    • 25,000 free text messages for other public sector service
    • +
    • 25,000 free text messages for other public sector services

    It costs 1.58 pence (plus VAT) for each text message you send after your free allowance.

    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 ed8628485..16446d9fb 100644 --- a/app/templates/views/service-settings/request-to-go-live.html +++ b/app/templates/views/service-settings/request-to-go-live.html @@ -4,6 +4,7 @@ {% from "components/radios.html" import radios %} {% from "components/page-footer.html" import page_footer %} {% from "components/banner.html" import banner_wrapper %} +{% from "components/tick-cross.html" import tick_cross_done_not_done %} {% block service_page_title %} Request to go live @@ -14,21 +15,35 @@

    Request to go live

    - Before you request to go live, make sure you’ve: + Before you request to go live, make sure that: +

    +
    +

    + You also need to:

    • read our terms of use
    • - added team members to your account -
    • -
    • - specified your reply to email address or text message sender in your - settings page -
    • -
    • - added the templates you want to start with, making sure they follow the GOV.UK Service Manual standards for + make sure your messages follow the GOV.UK Service Manual standards for writing text messages and emails
    diff --git a/tests/app/main/views/test_service_settings.py b/tests/app/main/views/test_service_settings.py index e31f3737b..715c6690e 100644 --- a/tests/app/main/views/test_service_settings.py +++ b/tests/app/main/views/test_service_settings.py @@ -455,18 +455,76 @@ def test_should_raise_duplicate_name_handled( assert mock_verify_password.called +@pytest.mark.parametrize('count_of_users_with_manage_service, expected_user_checklist_item', [ + (1, 'Not done: Another person in your team has the ‘Manage service’ permission'), + (2, 'Done: Another person in your team has the ‘Manage service’ permission'), +]) +@pytest.mark.parametrize('count_of_templates, expected_templates_checklist_item', [ + (0, 'Not done: You’ve added some templates'), + (1, 'Done: You’ve added some templates'), + (2, 'Done: You’ve added some templates'), +]) +@pytest.mark.parametrize('count_of_email_templates, reply_to_email_addresses, expected_reply_to_checklist_item', [ + pytest.mark.xfail((0, [], ''), raises=IndexError), + pytest.mark.xfail((0, [{}], ''), raises=IndexError), + (1, [], 'Not done: You’ve added an email reply to address on the settings page'), + (1, [{}], 'Done: You’ve added an email reply to address on the settings page'), +]) def test_should_show_request_to_go_live_checklist( client_request, + mocker, + count_of_users_with_manage_service, + expected_user_checklist_item, + count_of_templates, + expected_templates_checklist_item, + count_of_email_templates, + reply_to_email_addresses, + expected_reply_to_checklist_item, ): + + def _count_templates(service_id, template_type=None): + return { + 'email': count_of_email_templates + }.get(template_type, count_of_templates) + + mock_count_users = mocker.patch( + 'app.main.views.service_settings.user_api_client.get_count_of_users_with_permission', + return_value=count_of_users_with_manage_service + ) + mock_count_templates = mocker.patch( + 'app.main.views.service_settings.service_api_client.count_service_templates', + side_effect=_count_templates + ) + mock_get_reply_to_email_addresses = mocker.patch( + 'app.main.views.service_settings.service_api_client.get_reply_to_email_addresses', + return_value=reply_to_email_addresses + ) + page = client_request.get( 'main.request_to_go_live', service_id=SERVICE_ONE_ID ) assert page.h1.text == 'Request to go live' + + checklist_items = page.select('main ul[class=bottom-gutter] li') + + assert normalize_spaces(checklist_items[0].text) == expected_user_checklist_item + assert normalize_spaces(checklist_items[1].text) == expected_templates_checklist_item + assert normalize_spaces(checklist_items[2].text) == expected_reply_to_checklist_item + assert page.select_one('main .button')['href'] == url_for( 'main.submit_request_to_go_live', service_id=SERVICE_ONE_ID, ) + mock_count_users.assert_called_once_with(SERVICE_ONE_ID, 'manage_settings') + assert mock_count_templates.call_args_list == [ + call(SERVICE_ONE_ID), + call(SERVICE_ONE_ID, template_type='email'), + ] + + if count_of_email_templates: + mock_get_reply_to_email_addresses.assert_called_once_with(SERVICE_ONE_ID) + def test_should_show_request_to_go_live( client_request, @@ -564,6 +622,7 @@ def test_route_permissions( single_sms_sender, route, mock_get_service_settings_page_common, + mock_get_service_templates, ): validate_route_permission( mocker, @@ -593,6 +652,7 @@ def test_route_invalid_permissions( api_user_active, service_one, route, + mock_get_service_templates, ): validate_route_permission( mocker, @@ -624,6 +684,7 @@ def test_route_for_platform_admin( single_sms_sender, route, mock_get_service_settings_page_common, + mock_get_service_templates, ): validate_route_permission(mocker, app_,