diff --git a/app/__init__.py b/app/__init__.py index 7fd35e8be..4bbe79a4b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -442,15 +442,13 @@ def format_notification_status_as_field_status(status, notification_type): ).get(status, 'error') -def format_notification_status_as_url(status, notification_type): - if notification_type == 'letter': - return None - url = partial(url_for, "main.using_notify") +def format_notification_status_as_url(notification_type): + url = partial(url_for, "main.message_status") + return { - 'technical-failure': url(_anchor='technical-failure'), - 'temporary-failure': url(_anchor='not-accepting-messages'), - 'permanent-failure': url(_anchor='does-not-exist') - }.get(status) + 'email': url(_anchor='email-statuses'), + 'sms': url(_anchor='sms-statuses') + }.get(notification_type) def nl2br(value): diff --git a/app/main/views/api_keys.py b/app/main/views/api_keys.py index b4d4b52bb..91d87c163 100644 --- a/app/main/views/api_keys.py +++ b/app/main/views/api_keys.py @@ -98,7 +98,7 @@ def create_api_key(service_id): disabled_options = [KEY_TYPE_NORMAL] option_hints[KEY_TYPE_NORMAL] = Markup( 'Not available because your service is in ' - 'trial mode'.format(url_for(".using_notify")) + 'trial mode' ) if current_service.has_permission('letter'): option_hints[KEY_TYPE_TEAM] = 'Can’t be used to send letters' diff --git a/app/templates/components/table.html b/app/templates/components/table.html index 656ef1c47..b1bfbabbb 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -154,11 +154,11 @@ align='right' ) %} {% if displayed_on_single_line %}{% endif %} - {% if notification.status|format_notification_status_as_url(notification.notification_type) %} - + {% if notification.notification_type|format_notification_status_as_url %} + {% endif %} {{ notification.status|format_notification_status(notification.template.template_type) }} - {% if notification.status|format_notification_status_as_url(notification.notification_type) %} + {% if notification.notification_type|format_notification_status_as_url %} {% endif %} diff --git a/app/templates/partials/notifications/status.html b/app/templates/partials/notifications/status.html index d90e82462..8c92ed907 100644 --- a/app/templates/partials/notifications/status.html +++ b/app/templates/partials/notifications/status.html @@ -1,12 +1,12 @@

- {% if notification.status|format_notification_status_as_url(notification.notification_type) %} - + {% if notification.notification_type|format_notification_status_as_url %} + {% endif %} {{ notification.status|format_notification_status( notification.template.template_type ) }} - {% if notification.status|format_notification_status_as_url(notification.notification_type) %} + {% if notification.notification_type|format_notification_status_as_url %} {% endif %} {% if sent_with_test_key %} diff --git a/app/templates/views/message-status.html b/app/templates/views/message-status.html index 26e168d90..3aed37fad 100644 --- a/app/templates/views/message-status.html +++ b/app/templates/views/message-status.html @@ -31,7 +31,7 @@

These are the types of message status you’ll see when you’re signed in to Notify.

If you’re using our API, some of the statuses you’ll see will be different. Read our documentation for a detailed list of API message statuses.

-

Emails

+

Emails

{% call mapping_table( caption='Message statuses – emails', @@ -54,7 +54,7 @@ {% endcall %}
-

Text messages

+

Text messages

{% call mapping_table( caption='Message statuses – text messages', @@ -77,7 +77,7 @@ {% endfor %} {% endcall %}
- +

Letters

{% call mapping_table( diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index 84106ff66..606ac5e7a 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -521,7 +521,10 @@ def test_html_contains_links_for_failed_notifications( mock_get_service_data_retention, mocker, ): - mock_get_notifications(mocker, active_user_with_permissions, noti_status='technical-failure') + mock_get_notifications(mocker, + active_user_with_permissions, + diff_template_type="sms", + noti_status='technical-failure') response = client_request.get( 'main.view_notifications', service_id=SERVICE_ONE_ID, diff --git a/tests/app/main/views/test_index.py b/tests/app/main/views/test_index.py index 3d3088bd2..44e5dc411 100644 --- a/tests/app/main/views/test_index.py +++ b/tests/app/main/views/test_index.py @@ -114,6 +114,15 @@ def test_old_static_pages_redirect( ) +def test_message_status_page_contains_message_status_ids(client_request): + # The 'email-statuses' and 'sms-statuses' id are linked to when we display a message status, + # so this test ensures we don't accidentally remove them + page = client_request.get('main.message_status') + + assert page.find(id='email-statuses') + assert page.find(id='sms-statuses') + + def test_old_using_notify_page(client_request): client_request.get('main.using_notify', _expected_status=410)