From 2789b6a5965deb6a4c5e6c912ed7bb59c117862b Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 30 Jul 2020 16:20:19 +0100 Subject: [PATCH 1/2] Tell users that they can search whole postal address MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We’re now normalising and storing the whole address in the `normalised_to` field. Previously we were only storing the first line of the address. Enough time should now have passed that the field will have been populated for all letters in the database. Thus we can now tell users that it’s not just the first line they can search by. --- app/main/views/jobs.py | 4 +--- tests/app/main/views/test_activity.py | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/main/views/jobs.py b/app/main/views/jobs.py index 148bfcb53..0e5f37266 100644 --- a/app/main/views/jobs.py +++ b/app/main/views/jobs.py @@ -171,9 +171,7 @@ def view_notifications(service_id, message_type=None): things_you_can_search_by={ 'email': ['email address'], 'sms': ['phone number'], - # This should become ‘postal address’ not ‘first line…’ once - # we’ve finished populating normalised addresses - 'letter': ['first line of address', 'file name'], + 'letter': ['postal address', 'file name'], # We say recipient here because combining all 3 types, plus # reference gets too long for the hint text None: ['recipient'], diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index 3671b0992..363ec6c7c 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -402,7 +402,7 @@ def test_shows_message_when_no_notifications( { 'to': 'Firstname Lastname', }, - 'Search by first line of address or file name', + 'Search by postal address or file name', 'Firstname Lastname', ), ]) @@ -448,7 +448,7 @@ def test_search_recipient_form( (None, 'Search by recipient or reference'), ('sms', 'Search by phone number or reference'), ('email', 'Search by email address or reference'), - ('letter', 'Search by first line of address, file name or reference'), + ('letter', 'Search by postal address, file name or reference'), ]) def test_api_users_are_told_they_can_search_by_reference_when_service_has_api_keys( client_request, @@ -473,7 +473,7 @@ def test_api_users_are_told_they_can_search_by_reference_when_service_has_api_ke (None, 'Search by recipient'), ('sms', 'Search by phone number'), ('email', 'Search by email address'), - ('letter', 'Search by first line of address or file name'), + ('letter', 'Search by postal address or file name'), ]) def test_api_users_are_not_told_they_can_search_by_reference_when_service_has_no_api_keys( client_request, From 3fbf9667198e38ef2ff91ee5a866c5a78abf624f Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 30 Jul 2020 16:40:25 +0100 Subject: [PATCH 2/2] Display full address on the notifications page This is what we do on the uploads page now. It makes it more obvious why your search term has returned a certain result if you can see most of the address, not just the first line. --- app/templates/views/activity/notifications.html | 2 +- tests/app/main/views/test_activity.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/templates/views/activity/notifications.html b/app/templates/views/activity/notifications.html index a7bc6b741..17e7e0df9 100644 --- a/app/templates/views/activity/notifications.html +++ b/app/templates/views/activity/notifications.html @@ -19,7 +19,7 @@ {% if item.status in ('pending-virus-check', 'virus-scan-failed') %} Checking {% else %} - {{ item.to.splitlines()[0].lstrip().rstrip(' ,') if item.to else '' }} + {{ item.to.splitlines()|join(', ') if item.to else '' }} {% endif %}

{{ item.preview_of_content }} diff --git a/tests/app/main/views/test_activity.py b/tests/app/main/views/test_activity.py index 363ec6c7c..fffb23471 100644 --- a/tests/app/main/views/test_activity.py +++ b/tests/app/main/views/test_activity.py @@ -757,8 +757,8 @@ def test_sending_status_hint_displays_correctly_on_notifications_page( @pytest.mark.parametrize("is_precompiled_letter,expected_address,expected_hint", [ - (True, "Full Name,\nFirst address line\npostcode", "ref"), - (False, "Full Name,\nFirst address line\npostcode", "template subject") + (True, "Full Name\nFirst address line\npostcode", "ref"), + (False, "Full Name\nFirst address line\npostcode", "template subject") ]) def test_should_show_address_and_hint_for_letters( client_request, @@ -786,5 +786,5 @@ def test_should_show_address_and_hint_for_letters( message_type='letter', ) - assert page.select_one('a.file-list-filename').text == 'Full Name' + assert page.select_one('a.file-list-filename').text == 'Full Name, First address line, postcode' assert page.find('p', {'class': 'file-list-hint'}).text.strip() == expected_hint