mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-04-04 09:31:11 -04:00
Skip over placeholders if they’re in the address
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.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user