From b1852f4b78da1ec4a0aa3214883327cf6a1b1eb0 Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 7 Jun 2016 16:35:03 +0100 Subject: [PATCH] Make permanent failure status more human MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replace with ‘Phone number doesn’t exist’ or ‘Email address doesn’t’ exist. --- app/__init__.py | 28 +++++++++++++++++--------- app/templates/views/notifications.html | 15 ++++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/app/__init__.py b/app/__init__.py index cb370773b..e2f4a6f2b 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -229,15 +229,25 @@ def valid_phone_number(phone_number): return False -def format_notification_status(status): - m = {'failed': 'Failed', - 'technical-failure': 'Technical failure', - 'temporary-failure': 'Temporarily failed', - 'permanent-failure': 'Permanently failed', - 'delivered': 'Delivered', - 'sending': 'Sending' - } - return m.get(status, status) +def format_notification_status(status, template_type): + return { + 'email': { + 'failed': 'Failed', + 'technical-failure': 'Technical failure', + 'temporary-failure': 'Temporary failure', + 'permanent-failure': 'Email address does not exist', + 'delivered': 'Delivered', + 'sending': 'Sending' + }, + 'sms': { + 'failed': 'Failed', + 'technical-failure': 'Technical failure', + 'temporary-failure': 'Temporary failure', + 'permanent-failure': 'Phone number does not exist', + 'delivered': 'Delivered', + 'sending': 'Sending' + } + }.get(template_type).get(status, status) @login_manager.user_loader diff --git a/app/templates/views/notifications.html b/app/templates/views/notifications.html index cee5a602f..41bd3b6cb 100644 --- a/app/templates/views/notifications.html +++ b/app/templates/views/notifications.html @@ -46,7 +46,7 @@ caption="Recent activity", caption_visible=False, empty_message='No messages found', - field_headings=['Recipient', 'Status', 'Started'], + field_headings=['Recipient', 'Error', 'Status', 'Started'], field_headings_visible=False ) %} @@ -56,19 +56,22 @@

{% if item.job %} - From {{ item.job.original_file_name }} + From {{ item.job.original_file_name }} {% else %} - {{ item.template.name }} + {{ item.template.name }} from an API call {% endif %}

{% endcall %} - {{ text_field(item.status|format_notification_status) }} + {{ date_field( + (item.updated_at or item.created_at)|format_datetime_short + ) }} - {% call field(align='right') %} - {{ (item.updated_at or item.created_at)|format_datetime_short }} + {% call field(status='', align='right') %} + {{ item.status|format_notification_status(item.template.template_type) }} {% endcall %} + {% endcall %} {{ previous_next_navigation(prev_page, next_page) }}