Convert radios on edit org agreement page (basic)

This commit is contained in:
Tom Byers
2020-06-26 17:49:07 +01:00
parent 6aaa4d906b
commit 45526598c6
3 changed files with 44 additions and 40 deletions

View File

@@ -1182,16 +1182,21 @@ class OrganisationCrownStatusForm(StripWhitespaceForm):
class OrganisationAgreementSignedForm(StripWhitespaceForm): class OrganisationAgreementSignedForm(StripWhitespaceForm):
agreement_signed = RadioField( agreement_signed = GovukRadiosField(
( 'Has this organisation signed the agreement?',
'Has this organisation signed the agreement?'
),
choices=[ choices=[
('yes', 'Yes'), ('yes', 'Yes'),
('no', 'No'), ('no', 'No'),
('unknown', 'No (but we have some service-specific agreements in place)'), ('unknown', 'No (but we have some service-specific agreements in place)'),
], ],
thing='whether this organisation has signed the agreement', thing='whether this organisation has signed the agreement',
param_extensions={
'items': [
{'hint': {'html': 'Users will be told their organisation has already signed the agreement'}},
{'hint': {'html': 'Users will be prompted to sign the agreement before they can go live'}},
{'hint': {'html': 'Users will not be prompted to sign the agreement'}}
]
}
) )

View File

@@ -17,14 +17,7 @@
<div class="govuk-grid-row"> <div class="govuk-grid-row">
<div class="govuk-grid-column-five-sixths"> <div class="govuk-grid-column-five-sixths">
{% call form_wrapper() %} {% call form_wrapper() %}
{{ radios( {{ form.agreement_signed }}
form.agreement_signed,
option_hints={
'yes': 'Users will be told their organisation has already signed the agreement',
'no': 'Users will be prompted to sign the agreement before they can go live',
'unknown': 'Users will not be prompted to sign the agreement'
}
) }}
{{ page_footer('Save') }} {{ page_footer('Save') }}
{% endcall %} {% endcall %}
</div> </div>

View File

@@ -704,41 +704,44 @@ def test_organisation_settings_for_platform_admin(
( (
'.edit_organisation_type', '.edit_organisation_type',
( (
('central', 'Central government'), {'value': 'central', 'label': 'Central government'},
('local', 'Local government'), {'value': 'local', 'label': 'Local government'},
('nhs_central', 'NHS central government agency or public body'), {'value': 'nhs_central', 'label': 'NHS central government agency or public body'},
('nhs_local', 'NHS Trust or Clinical Commissioning Group'), {'value': 'nhs_local', 'label': 'NHS Trust or Clinical Commissioning Group'},
('nhs_gp', 'GP practice'), {'value': 'nhs_gp', 'label': 'GP practice'},
('emergency_service', 'Emergency service'), {'value': 'emergency_service', 'label': 'Emergency service'},
('school_or_college', 'School or college'), {'value': 'school_or_college', 'label': 'School or college'},
('other', 'Other'), {'value': 'other', 'label': 'Other'},
), ),
'central', 'central',
), ),
( (
'.edit_organisation_crown_status', '.edit_organisation_crown_status',
( (
('crown', 'Yes'), {'value': 'crown', 'label': 'Yes'},
('non-crown', 'No'), {'value': 'non-crown', 'label': 'No'},
('unknown', 'Not sure'), {'value': 'unknown', 'label': 'Not sure'},
), ),
'crown', 'crown',
), ),
( (
'.edit_organisation_agreement', '.edit_organisation_agreement',
( (
('yes', ( {
'Yes ' 'value': 'yes',
'Users will be told their organisation has already signed the agreement' 'label': 'Yes',
)), 'hint': 'Users will be told their organisation has already signed the agreement'
('no', ( },
'No ' {
'Users will be prompted to sign the agreement before they can go live' 'value': 'no',
)), 'label': 'No',
('unknown', ( 'hint': 'Users will be prompted to sign the agreement before they can go live'
'No (but we have some service-specific agreements in place) ' },
'Users will not be prompted to sign the agreement' {
)), 'value': 'unknown',
'label': 'No (but we have some service-specific agreements in place)',
'hint': 'Users will not be prompted to sign the agreement'
},
), ),
'no', 'no',
), ),
@@ -769,11 +772,14 @@ def test_view_organisation_settings(
radios = page.select('input[type=radio]') radios = page.select('input[type=radio]')
for index, option in enumerate(expected_options): for index, option in enumerate(expected_options):
label = page.select_one('label[for={}]'.format(radios[index]['id'])) option_values = {
assert ( 'value': radios[index]['value'],
radios[index]['value'], 'label': normalize_spaces(page.select_one('label[for={}]'.format(radios[index]['id'])).text)
normalize_spaces(label.text), }
) == option if 'hint' in option:
option_values['hint'] = normalize_spaces(
page.select_one('label[for={}] + .govuk-hint'.format(radios[index]['id'])).text)
assert option_values == option
if expected_selected: if expected_selected:
assert page.select_one('input[checked]')['value'] == expected_selected assert page.select_one('input[checked]')['value'] == expected_selected