mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-13 01:44:08 -04:00
Remove the code to handle optional address placeholders
Optional address placeholders aren’t a thing for one-off letters any more, so we can tidy up the code a bit by removing the parts of the flow that are accounting for them.
This commit is contained in:
@@ -1372,7 +1372,6 @@ def get_placeholder_form_instance(
|
||||
placeholder_name,
|
||||
dict_to_populate_from,
|
||||
template_type,
|
||||
optional_placeholder=False,
|
||||
allow_international_phone_numbers=False,
|
||||
):
|
||||
|
||||
@@ -1389,8 +1388,6 @@ def get_placeholder_form_instance(
|
||||
field = international_phone_number(label=placeholder_name)
|
||||
else:
|
||||
field = uk_mobile_number(label=placeholder_name)
|
||||
elif optional_placeholder:
|
||||
field = StringField(placeholder_name)
|
||||
else:
|
||||
field = StringField(placeholder_name, validators=[
|
||||
DataRequired(message='Cannot be empty')
|
||||
|
||||
@@ -399,7 +399,6 @@ def send_one_off_letter_address(service_id, template_id):
|
||||
),
|
||||
template=template,
|
||||
form=form,
|
||||
optional_placeholder=False,
|
||||
back_link=get_back_link(service_id, template, 0),
|
||||
help=False,
|
||||
link_to_upload=True,
|
||||
@@ -478,12 +477,10 @@ def send_test_step(service_id, template_id, step_index):
|
||||
):
|
||||
return redirect(url_for('.send_one_off_letter_address', service_id=service_id, template_id=template_id))
|
||||
|
||||
optional_placeholder = (current_placeholder in optional_address_columns)
|
||||
form = get_placeholder_form_instance(
|
||||
current_placeholder,
|
||||
dict_to_populate_from=get_normalised_placeholders_from_session(),
|
||||
template_type=template.template_type,
|
||||
optional_placeholder=optional_placeholder,
|
||||
allow_international_phone_numbers=current_service.has_permission('international_sms'),
|
||||
)
|
||||
|
||||
@@ -540,7 +537,6 @@ def send_test_step(service_id, template_id, step_index):
|
||||
template=template,
|
||||
form=form,
|
||||
skip_link=skip_link,
|
||||
optional_placeholder=optional_placeholder,
|
||||
back_link=back_link,
|
||||
help=get_help_argument(),
|
||||
link_to_upload=(
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
<div class="govuk-grid-column-full {% if form.placeholder_value.label.text == 'phone number' %}extra-tracking{% endif %}">
|
||||
{{ textbox(
|
||||
form.placeholder_value,
|
||||
hint='Optional' if optional_placeholder else None,
|
||||
width='1-1',
|
||||
) }}
|
||||
</div>
|
||||
|
||||
@@ -9,11 +9,11 @@ def test_form_class_not_mutated(app_):
|
||||
method='POST',
|
||||
data={'placeholder_value': ''}
|
||||
):
|
||||
form1 = get_placeholder_form_instance('name', {}, 'sms', optional_placeholder=False)
|
||||
form2 = get_placeholder_form_instance('city', {}, 'sms', optional_placeholder=True)
|
||||
form1 = get_placeholder_form_instance('name', {}, 'sms')
|
||||
form2 = get_placeholder_form_instance('city', {}, 'sms')
|
||||
|
||||
assert not form1.validate_on_submit()
|
||||
assert form2.validate_on_submit()
|
||||
assert not form2.validate_on_submit()
|
||||
|
||||
assert str(form1.placeholder_value.label) == '<label for="placeholder_value">name</label>'
|
||||
assert str(form2.placeholder_value.label) == '<label for="placeholder_value">city</label>'
|
||||
|
||||
Reference in New Issue
Block a user