Make permanent failure status more human

Replace with ‘Phone number doesn’t exist’ or ‘Email address doesn’t’
exist.
This commit is contained in:
Chris Hill-Scott
2016-06-07 16:35:03 +01:00
parent 0a337a2663
commit b1852f4b78
2 changed files with 28 additions and 15 deletions

View File

@@ -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

View File

@@ -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 @@
</p>
<p class="hint">
{% if item.job %}
From <a href="{{ url_for(".view_job", service_id=current_service.id, job_id=item.job.id) }}">{{ item.job.original_file_name }}</a>
From <a class="truncated" href="{{ url_for(".view_job", service_id=current_service.id, job_id=item.job.id) }}">{{ item.job.original_file_name }}</a>
{% else %}
<a href="{{ url_for('.view_template_version', service_id=current_service.id, template_id=item.template.id, version=item.template_version) }}">{{ item.template.name }}</a>
<a class="truncated" href="{{ url_for('.view_template_version', service_id=current_service.id, template_id=item.template.id, version=item.template_version) }}">{{ item.template.name }}</a>
from an API call
{% endif %}
</p>
{% 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) }}