From b236df523cb978f162ef2d329416d91f03f1361b Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Tue, 3 Mar 2020 11:39:31 +0000 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20show=20the=20postage=20when=20v?= =?UTF-8?q?alidation=20has=20failed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The postage covers up some of the letter, so it can hide the problem. It also implies that the letter has been put in an envelope, which will never happen if it fails validation. This matches what we do for uploaded letters. --- app/main/views/notifications.py | 5 ++++- tests/app/main/views/test_notifications.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/main/views/notifications.py b/app/main/views/notifications.py index 5cff773e7..710d8f97d 100644 --- a/app/main/views/notifications.py +++ b/app/main/views/notifications.py @@ -78,7 +78,10 @@ def view_notification(service_id, notification_id): page_count = get_page_count_for_letter(notification['template'], values=personalisation) if notification.get('postage'): - notification['template']['postage'] = notification['postage'] + if notification["status"] == "validation-failed": + notification['template']['postage'] = None + else: + notification['template']['postage'] = notification['postage'] template = get_template( notification['template'], current_service, diff --git a/tests/app/main/views/test_notifications.py b/tests/app/main/views/test_notifications.py index 590e61c89..8062a17da 100644 --- a/tests/app/main/views/test_notifications.py +++ b/tests/app/main/views/test_notifications.py @@ -405,6 +405,7 @@ def test_notification_page_shows_validation_failed_precompiled_letter( assert not page.select('p.notification-status') assert page.select_one('main img')['src'].endswith('.png?page=1') + assert not page.select('.letter-postage') @pytest.mark.parametrize('notification_status, expected_message', (