From 1eb3a5aca0769c4079407b4f96f9e6591e84187e Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Mon, 19 Jun 2017 14:43:01 +0100 Subject: [PATCH] Link to the relevant job from notification page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a notification has been sent from a job then that’s important context to know about it. So we should surface that information on the page. It also gives users an easy way of going back, if that’s the page they’ve come from. --- app/main/views/notifications.py | 6 ++++++ .../views/notifications/notification.html | 14 ++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index c501eb0b1..20d309a21 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -10,6 +10,7 @@ from flask_login import login_required from app import ( notification_api_client, + job_api_client, current_service ) from app.main import main @@ -57,11 +58,16 @@ def view_notification(service_id, notification_id): show_recipient=True, ) template.values = notification['personalisation'] + if notification['job']: + job = job_api_client.get_job(service_id, notification['job']['id'])['data'] + else: + job = None return render_template( 'views/notifications/notification.html', finished=(notification['status'] in (DELIVERED_STATUSES + FAILURE_STATUSES)), uploaded_file_name='Report', template=template, + job=job, updates_url=url_for( ".view_notification_updates", service_id=service_id, diff --git a/app/templates/views/notifications/notification.html b/app/templates/views/notifications/notification.html index e077877fa..274776b22 100644 --- a/app/templates/views/notifications/notification.html +++ b/app/templates/views/notifications/notification.html @@ -15,7 +15,14 @@

- Sent {% if created_by %}by {{ created_by.name }} {% endif %} + {{ template.name }} + sent + {% if job %} + from + {{ job.original_file_name }} + {% elif created_by %} + by {{ created_by.name }} + {% endif %} on {{ created_at|format_datetime_short }}

@@ -23,9 +30,4 @@ {{ ajax_block(partials, updates_url, 'status', finished=finished) }} - {{ page_footer( - secondary_link=url_for('.view_template', service_id=current_service.id, template_id=template.id), - secondary_link_text='Back to {}'.format(template.name) - ) }} - {% endblock %}