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) }}