Skip to content

Commit 8eaaaba

Browse files
committed
Remove bound choice from choice field
1 parent 7107a6c commit 8eaaaba

File tree

5 files changed

+3
-91
lines changed

5 files changed

+3
-91
lines changed

lung_cancer_screening/nhsuk_forms/choice_field.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
from django import forms
22
from django.forms import widgets
33

4-
from .bound_choice_field import BoundChoiceField
5-
64
class ChoiceField(forms.ChoiceField):
75
"""
86
A ChoiceField that renders using NHS.UK design system radios/select
97
components.
108
"""
119

1210
widget = widgets.RadioSelect
13-
bound_field_class = BoundChoiceField
1411

1512
def __init__(
1613
self,

lung_cancer_screening/nhsuk_forms/jinja2/radios.jinja

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,12 @@
55
{% endif %}
66
{% set ns = namespace(items=[]) %}
77
{% for value, text in unbound_field.choices %}
8-
{% set conditional_html = field.conditional_html(value) %}
98
{% set ns.items = ns.items + [{
109
"id": field.auto_id if loop.first,
1110
"value": value,
1211
"text": text,
13-
"checked": field.value() == value,
14-
"conditional": {
15-
"html": conditional_html
16-
} if conditional_html else undefined
12+
"checked": field.value() == value
1713
}] %}
18-
{% set divider = field.get_divider_after(value) %}
19-
{% if divider %}
20-
{% set ns.items = ns.items + [{"divider": divider}] %}
21-
{% endif %}
2214
{% endfor %}
2315
{{ radios({
2416
"name": field.html_name,

lung_cancer_screening/nhsuk_forms/tests/unit/test_choice_field.py

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,3 @@ def test_renders_nhs_radios(self):
3838
</div>
3939
""",
4040
)
41-
42-
def test_renders_radios_with_conditional_html(self):
43-
form = TestForm()
44-
form["field"].add_conditional_html("b", "<p>Hello</p>")
45-
46-
self.assertHTMLEqual(
47-
form["field"].as_field_group(),
48-
"""
49-
<div class="nhsuk-form-group">
50-
<fieldset aria-describedby="id_field-hint" class="nhsuk-fieldset">
51-
<legend class="nhsuk-fieldset__legend app-abc">
52-
Abc
53-
</legend>
54-
<div class="nhsuk-hint" id="id_field-hint">
55-
Pick either one
56-
</div>
57-
<div class="nhsuk-radios nhsuk-radios--conditional" data-module="nhsuk-radios">
58-
<div class="nhsuk-radios__item">
59-
<input class="nhsuk-radios__input" id="id_field" name="field" type="radio" value="a">
60-
<label class="nhsuk-label nhsuk-radios__label" for="id_field">A</label>
61-
</div>
62-
<div class="nhsuk-radios__item">
63-
<input aria-controls="conditional-id_field-2" aria-expanded="false" class="nhsuk-radios__input" id="id_field-2" name="field" type="radio" value="b">
64-
<label class="nhsuk-label nhsuk-radios__label" for="id_field-2">B</label>
65-
</div>
66-
<div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-id_field-2">
67-
<p>Hello</p>
68-
</div>
69-
</div>
70-
</fieldset>
71-
</div>
72-
""",
73-
)
74-
75-
def test_adding_dividers_via_boundfield(self):
76-
bound_field = TestForm()["field"]
77-
bound_field.add_divider_after("a", "or")
78-
assert bound_field.get_divider_after("a") == "or"

lung_cancer_screening/nhsuk_forms/tests/unit/test_typed_choice_field.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
from ...typed_choice_field import TypedChoiceField
55

6-
76
class TestForm(Form):
87
field = TypedChoiceField(
98
label="Abc",
@@ -39,41 +38,3 @@ def test_renders_nhs_radios(self):
3938
</div>
4039
""",
4140
)
42-
43-
def test_renders_radios_with_conditional_html(self):
44-
form = TestForm()
45-
form["field"].add_conditional_html("b", "<p>Hello</p>")
46-
47-
self.assertHTMLEqual(
48-
form["field"].as_field_group(),
49-
"""
50-
<div class="nhsuk-form-group">
51-
<fieldset aria-describedby="id_field-hint" class="nhsuk-fieldset">
52-
<legend class="nhsuk-fieldset__legend app-abc">
53-
Abc
54-
</legend>
55-
<div class="nhsuk-hint" id="id_field-hint">
56-
Pick either one
57-
</div>
58-
<div class="nhsuk-radios nhsuk-radios--conditional" data-module="nhsuk-radios">
59-
<div class="nhsuk-radios__item">
60-
<input class="nhsuk-radios__input" id="id_field" name="field" type="radio" value="a">
61-
<label class="nhsuk-label nhsuk-radios__label" for="id_field">A</label>
62-
</div>
63-
<div class="nhsuk-radios__item">
64-
<input aria-controls="conditional-id_field-2" aria-expanded="false" class="nhsuk-radios__input" id="id_field-2" name="field" type="radio" value="b">
65-
<label class="nhsuk-label nhsuk-radios__label" for="id_field-2">B</label>
66-
</div>
67-
<div class="nhsuk-radios__conditional nhsuk-radios__conditional--hidden" id="conditional-id_field-2">
68-
<p>Hello</p>
69-
</div>
70-
</div>
71-
</fieldset>
72-
</div>
73-
""",
74-
)
75-
76-
def test_adding_dividers_via_boundfield(self):
77-
bound_field = TestForm()["field"]
78-
bound_field.add_divider_after("a", "or")
79-
assert bound_field.get_divider_after("a") == "or"

lung_cancer_screening/questions/tests/unit/views/test_sex_at_birth.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def setUp(self):
1414
session['participant_id'] = self.participant.unique_id
1515
session.save()
1616

17-
def test_get_redirects_if_the_particpant_does_not_exist(self):
17+
def test_get_redirects_if_the_participant_does_not_exist(self):
1818
session = self.client.session
1919
session['participant_id'] = "somebody none existant participant"
2020
session.save()
@@ -35,7 +35,7 @@ def test_get_contains_the_correct_form_fields(self):
3535

3636
self.assertContains(response, "What was your sex at birth?")
3737

38-
def test_post_redirects_if_the_particpant_does_not_exist(self):
38+
def test_post_redirects_if_the_participant_does_not_exist(self):
3939
session = self.client.session
4040
session['participant_id'] = "somebody none existant participant"
4141
session.save()

0 commit comments

Comments
 (0)