Always go back to previous page from notification

When looking at a notification you can either be coming from the page
of all notifications, or from a job. Currently the back link always
takes you to the page of all notifications.

This commit makes it a bit more sophisticated so if you’ve come from
looking at a job, you go back to the job.
This commit is contained in:
Chris Hill-Scott
2019-05-09 17:33:22 +01:00
parent b786997c6b
commit b4894e7a03
6 changed files with 73 additions and 3 deletions

View File

@@ -101,6 +101,21 @@ def view_notification(service_id, notification_id):
show_cancel_button = notification['notification_type'] == 'letter' and \
letter_can_be_cancelled(notification['status'], notification_created)
if request.args.get('help') == '0':
back_link = None
elif request.args.get('from_job'):
back_link = url_for(
'main.view_job',
service_id=current_service.id,
job_id=request.args.get('from_job'),
)
else:
back_link = url_for(
'main.view_notifications',
service_id=current_service.id,
message_type=template.template_type,
)
return render_template(
'views/notifications/notification.html',
finished=(notification['status'] in (DELIVERED_STATUSES + FAILURE_STATUSES)),
@@ -133,6 +148,7 @@ def view_notification(service_id, notification_id):
sent_with_test_key=(
notification.get('key_type') == KEY_TYPE_TEST
),
back_link=back_link,
)