From b68dd569fc8cadebd255dbe96d8dffca8f4cff3d Mon Sep 17 00:00:00 2001 From: Chris Hill-Scott Date: Thu, 9 Apr 2020 15:45:30 +0100 Subject: [PATCH] =?UTF-8?q?Skip=20over=20placeholders=20if=20they=E2=80=99?= =?UTF-8?q?re=20in=20the=20address?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don’t really want you modifying lines of the address after you’ve entered it. Especially when it might not be obvious that modifying the address line placeholder will modify the address you’re sending the letter to. --- app/main/views/send.py | 19 +++++++++++++++---- tests/app/main/views/test_send.py | 8 ++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/main/views/send.py b/app/main/views/send.py index acea53a57..f4aa8e4ee 100644 --- a/app/main/views/send.py +++ b/app/main/views/send.py @@ -472,10 +472,21 @@ def send_test_step(service_id, template_id, step_index): )) # if we're in a letter, we should show address block rather than "address line #" or "postcode" - if template.template_type == 'letter' and ( - step_index < len(first_column_headings['letter']) - ): - return redirect(url_for('.send_one_off_letter_address', service_id=service_id, template_id=template_id)) + if template.template_type == 'letter': + if step_index < len(first_column_headings['letter']): + return redirect(url_for( + '.send_one_off_letter_address', + service_id=service_id, + template_id=template_id, + )) + if current_placeholder in Columns(PostalAddress('').as_personalisation): + return redirect(url_for( + request.endpoint, + service_id=service_id, + template_id=template_id, + step_index=step_index + 1, + help=get_help_argument(), + )) form = get_placeholder_form_instance( current_placeholder, diff --git a/tests/app/main/views/test_send.py b/tests/app/main/views/test_send.py index 09f54b723..1e2af293f 100644 --- a/tests/app/main/views/test_send.py +++ b/tests/app/main/views/test_send.py @@ -2091,11 +2091,11 @@ def test_send_one_off_letter_copes_with_placeholder_from_address_block( _follow_redirects=True, ) + assert normalize_spaces(page.select_one('form label').text) == 'thing' + assert page.select_one('form input[type=text]')['name'] == 'placeholder_value' + assert page.select_one('form input[type=text]')['value'] == '' + with client_request.session_transaction() as session: - assert normalize_spaces(page.select_one('form label').text) == placeholder - assert page.select_one('form input[type=text]')['value'] == ( - session['placeholders'].get(placeholder, '') - ) assert session['placeholders'] == { 'address_line_1': 'foo', 'address_line_2': 'bar',