From 989875294b8bf56fd8b0b686323c61ba8e5caa7d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 10 Jan 2019 17:23:03 +0000 Subject: [PATCH 1/3] Make technical failure letters show up on the activity page --- app/__init__.py | 22 ++++++++++++---------- app/templates/components/table.html | 11 ++--------- tests/app/main/views/test_activity.py | 6 ++++++ 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index 75837af07..cffa0297f 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -362,18 +362,20 @@ def format_notification_status(status, template_type): 'sent': 'Sent internationally' }, 'letter': { - 'failed': 'Failed', + 'failed': '', 'technical-failure': 'Technical failure', - 'temporary-failure': 'Temporary failure', - 'permanent-failure': 'Permanent failure', - 'delivered': 'Delivered', - 'sending': 'Sending', - 'created': 'Sending', - 'sent': 'Delivered', - 'pending-virus-check': 'Pending virus check', + 'temporary-failure': '', + 'permanent-failure': 'Cancelled', + 'delivered': '', + 'received': '', + 'accepted': '', + 'sending': '', + 'created': '', + 'sent': '', + 'pending-virus-check': '', 'virus-scan-failed': 'Virus detected', - 'returned-letter': 'Delivered', - 'cancelled': 'Cancelled,', + 'returned-letter': '', + 'cancelled': '', 'validation-failed': 'Validation failed', } }[template_type].get(status, status) diff --git a/app/templates/components/table.html b/app/templates/components/table.html index b4863e947..c5708512c 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -144,7 +144,7 @@ {% macro notification_status_field(notification) %} - {% set displayed_on_single_line = notification.status in ['created', 'pending', 'sending', 'delivered'] %} + {% set displayed_on_single_line = notification.status in ['created', 'pending', 'pending-virus-check', 'sending', 'sent', 'delivered', 'returned-letter', 'accepted', 'received'] %} {% if not notification %} {% call field(align='right') %}{% endcall %} @@ -157,14 +157,7 @@ {% if notification.status|format_notification_status_as_url(notification.notification_type) %} {% endif %} - {% if notification['notification_type'] != "letter" or notification.status in ('virus-scan-failed', 'validation-failed') %} - {{ notification.status|format_notification_status( - notification.template.template_type - ) }} - {% endif %} - {% if notification.notification_type == "letter" and notification.status in ['permanent-failure', 'cancelled'] %} - Cancelled - {% endif %} + {{ notification.status|format_notification_status(notification.template.template_type) }} {% if notification.status|format_notification_status_as_url(notification.notification_type) %} {% endif %} diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index a662b9996..bb7dd7546 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -603,9 +603,15 @@ def test_big_numbers_and_search_dont_show_for_letters( "message_type, status, expected_hint_status, single_line", [ ('email', 'delivered', 'Delivered 27 September at 5:31pm', True), ('sms', 'delivered', 'Delivered 27 September at 5:31pm', True), + ('letter', 'created', '27 September at 5:30pm', True), + ('letter', 'sending', '27 September at 5:30pm', True), ('letter', 'delivered', '27 September at 5:30pm', True), + ('letter', 'received', '27 September at 5:30pm', True), + ('letter', 'accepted', '27 September at 5:30pm', True), + ('letter', 'virus-scan-failed', 'Virus detected 27 September at 5:30pm', False), ('letter', 'permanent-failure', 'Cancelled 27 September at 5:31pm', False), ('letter', 'validation-failed', 'Validation failed 27 September at 5:30pm', False), + ('letter', 'technical-failure', 'Technical failure 27 September at 5:30pm', False), ] ) def test_sending_status_hint_displays_correctly_on_notifications_page( From c1158d7d7031536cdb404e497e4ded31854736e8 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 10 Jan 2019 17:25:23 +0000 Subject: [PATCH 2/3] Explain technical failure on the notification page --- .../views/notifications/notification.html | 5 ++++ tests/app/main/views/test_notifications.py | 25 ++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index cab6d4765..eda9a1460 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -45,6 +45,11 @@

Validation failed – content is outside the printable area

+ {% elif notification_status == 'technical-failure' %} +

+ Technical failure – Notify will resend once the team have + fixed the problem +

{% else %}

{{ letter_print_day }} diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 40125b565..ba926a159 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -191,13 +191,26 @@ def test_notification_page_shows_page_for_letter_notification( assert mock_page_count.call_args_list[0][1]['values'] == {'name': 'Jo'} -@pytest.mark.parametrize('notification_status, expected_message', [ - ('permanent-failure', 'Cancelled 1 January at 1:02am'), - ('cancelled', 'Cancelled 1 January at 1:02am'), - ('validation-failed', 'Validation failed – content is outside the printable area'), -]) +@pytest.mark.parametrize('notification_status, expected_message', ( + ( + 'permanent-failure', + 'Cancelled 1 January at 1:02am', + ), + ( + 'cancelled', + 'Cancelled 1 January at 1:02am', + ), + ( + 'validation-failed', + 'Validation failed – content is outside the printable area', + ), + ( + 'technical-failure', + 'Technical failure – Notify will resend once the team have fixed the problem', + ), +)) @freeze_time("2016-01-01 01:01") -def test_notification_page_shows_cancelled_letter( +def test_notification_page_shows_cancelled_or_failed_letter( client_request, mocker, fake_uuid, From 5c4ff09d480dd8d60c8c79db2655c9893428f1aa Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 14 Jan 2019 09:57:36 +0000 Subject: [PATCH 3/3] Treat permanent failure for letters the same as cancelled --- app/__init__.py | 2 +- app/templates/components/table.html | 2 +- tests/app/main/views/test_activity.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index cffa0297f..69ad58a25 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -365,7 +365,7 @@ def format_notification_status(status, template_type): 'failed': '', 'technical-failure': 'Technical failure', 'temporary-failure': '', - 'permanent-failure': 'Cancelled', + 'permanent-failure': '', 'delivered': '', 'received': '', 'accepted': '', diff --git a/app/templates/components/table.html b/app/templates/components/table.html index c5708512c..80e118059 100644 --- a/app/templates/components/table.html +++ b/app/templates/components/table.html @@ -144,7 +144,7 @@ {% macro notification_status_field(notification) %} - {% set displayed_on_single_line = notification.status in ['created', 'pending', 'pending-virus-check', 'sending', 'sent', 'delivered', 'returned-letter', 'accepted', 'received'] %} + {% set displayed_on_single_line = notification.status in ['created', 'pending', 'pending-virus-check', 'sending', 'sent', 'delivered', 'returned-letter', 'accepted', 'received', 'permanent-failure'] %} {% if not notification %} {% call field(align='right') %}{% endcall %} diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index bb7dd7546..54d8989fe 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -608,8 +608,8 @@ def test_big_numbers_and_search_dont_show_for_letters( ('letter', 'delivered', '27 September at 5:30pm', True), ('letter', 'received', '27 September at 5:30pm', True), ('letter', 'accepted', '27 September at 5:30pm', True), + ('letter', 'permanent-failure', '27 September at 5:31pm', True), ('letter', 'virus-scan-failed', 'Virus detected 27 September at 5:30pm', False), - ('letter', 'permanent-failure', 'Cancelled 27 September at 5:31pm', False), ('letter', 'validation-failed', 'Validation failed 27 September at 5:30pm', False), ('letter', 'technical-failure', 'Technical failure 27 September at 5:30pm', False), ]