Skip to content

Commit b6c19f1

Browse files
committed
PPHA-512: Move Check answers summaryList logic to presenter
1 parent fd767c2 commit b6c19f1

5 files changed

Lines changed: 82 additions & 147 deletions

File tree

features/education.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ Feature: Education page
2828
And I check "GCSEs"
2929
And I click "Continue"
3030
When I go to "/check-your-answers"
31-
Then I see "GCSEs and A-levels" as a response to "Highest level of education" under "About you"
32-
And I see "/education?change=True" as a link to change "Highest level of education" under "About you"
33-
When I click the link to change "Highest level of education" under "About you"
31+
Then I see "GCSEs and A-levels" as a response to "Education" under "About you"
32+
And I see "/education?change=True" as a link to change "Education" under "About you"
33+
When I click the link to change "Education" under "About you"
3434
Then I am on "/education?change=True"
3535
And I see "A-levels" selected
3636
When I fill in and submit my education with "GCSEs"
3737
Then I am on "/check-your-answers"
38-
And I see "GCSEs" as a response to "Highest level of education" under "About you"
38+
And I see "GCSEs" as a response to "Education" under "About you"
3939

features/ethnicity.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ Feature: Ethnicity page
2525
When I go to "/ethnicity"
2626
And I fill in and submit my ethnicity with "White"
2727
When I go to "/check-your-answers"
28-
Then I see "White" as a response to "Ethnic group" under "About you"
29-
And I see "/ethnicity?change=True" as a link to change "Ethnic group" under "About you"
30-
When I click the link to change "Ethnic group" under "About you"
28+
Then I see "White" as a response to "Ethnic background" under "About you"
29+
And I see "/ethnicity?change=True" as a link to change "Ethnic background" under "About you"
30+
When I click the link to change "Ethnic background" under "About you"
3131
Then I am on "/ethnicity?change=True"
3232
And I see "White" selected
3333
When I fill in and submit my ethnicity with "Black, African, Caribbean or Black British"
3434
Then I am on "/check-your-answers"
35-
And I see "Black, African, Caribbean or Black British" as a response to "Ethnic group" under "About you"
35+
And I see "Black, African, Caribbean or Black British" as a response to "Ethnic background" under "About you"
3636

features/questionnaire.feature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ Feature: Questionnaire
6666
And I see "5 stone 10 pounds" as a response to "Weight" under "About you"
6767
And I see "Male" as a response to "Sex at birth" under "About you"
6868
And I see "Female" as a response to "Gender identity" under "About you"
69-
And I see "White" as a response to "Ethnic group" under "About you"
69+
And I see "White" as a response to "Ethnic background" under "About you"
7070

7171
And I see "Pneumonia and Emphysema" as a response to "Diagnosed respiratory conditions" under "Your health"
7272
And I see "No" as a response to "Have you ever worked in a job where you were exposed to asbestos?" under "Your health"

lung_cancer_screening/questions/jinja2/responses.jinja

Lines changed: 3 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -13,156 +13,21 @@
1313
<section>
1414
<h2 class="nhsuk-heading-m">Eligibility</h2>
1515
{{ summaryList({
16-
"rows": [
17-
{
18-
"key": { "text": "Have you ever smoked tobacco?" },
19-
"value": { "text": response_set.have_you_ever_smoked },
20-
"actions": {
21-
"items": [
22-
{
23-
"href": url('questions:have_you_ever_smoked', query = change_query_params),
24-
"text": "Change"
25-
}
26-
]
27-
}
28-
},
29-
{
30-
"key": { "text": "Date of birth" },
31-
"value": { "text": response_set.date_of_birth },
32-
"actions": {
33-
"items": [
34-
{
35-
"href": url('questions:date_of_birth', query = change_query_params),
36-
"text": "Change"
37-
}
38-
]
39-
}
40-
}
41-
]
16+
"rows": response_set.eligibility_responses_items()
4217
}) }}
4318
</section>
4419

4520
<section>
4621
<h2 class="nhsuk-heading-m">About you</h2>
4722
{{ summaryList({
48-
"rows": [
49-
{
50-
"key": { "text": "Height" },
51-
"value": { "text": response_set.height },
52-
"actions": {
53-
"items": [
54-
{
55-
"href": url('questions:height', query = change_query_params),
56-
"text": "Change"
57-
}
58-
]
59-
}
60-
},
61-
{
62-
"key": { "text": "Weight" },
63-
"value": { "text": response_set.weight },
64-
"actions": {
65-
"items": [
66-
{
67-
"href": url('questions:weight', query = change_query_params),
68-
"text": "Change"
69-
}
70-
]
71-
}
72-
},
73-
{
74-
"key": { "text": "Sex at birth" },
75-
"value": { "text": response_set.sex_at_birth },
76-
"actions": {
77-
"items": [
78-
{
79-
"href": url('questions:sex_at_birth', query = change_query_params),
80-
"text": "Change"
81-
}
82-
]
83-
}
84-
},
85-
{
86-
"key": { "text": "Gender identity" },
87-
"value": { "text": response_set.gender },
88-
"actions": {
89-
"items": [
90-
{
91-
"href": url('questions:gender', query = change_query_params),
92-
"text": "Change"
93-
}
94-
]
95-
}
96-
},
97-
{
98-
"key": { "text": "Ethnic background" },
99-
"value": { "text": response_set.ethnicity },
100-
"actions": {
101-
"items": [
102-
{
103-
"href": url('questions:ethnicity', query = change_query_params),
104-
"text": "Change"
105-
}
106-
]
107-
}
108-
},
109-
{
110-
"key": { "text": "Education" },
111-
"value": { "text": response_set.education },
112-
"actions": {
113-
"items": [
114-
{
115-
"href": url('questions:education', query = change_query_params),
116-
"text": "Change"
117-
}
118-
]
119-
}
120-
},
121-
]
23+
"rows": response_set.about_you_responses_items()
12224
}) }}
12325
</section>
12426

12527
<section>
12628
<h2 class="nhsuk-heading-m">Your health</h2>
12729
{{ summaryList({
128-
"rows": [
129-
{
130-
"key": { "text": "Diagnosed respiratory conditions" },
131-
"value": { "text": response_set.respiratory_conditions },
132-
"actions": {
133-
"items": [
134-
{
135-
"href": url('questions:respiratory_conditions', query = change_query_params),
136-
"text": "Change"
137-
}
138-
]
139-
}
140-
},
141-
{
142-
"key": { "text": "Have you ever worked in a job where you were exposed to asbestos?" },
143-
"value": { "text": response_set.asbestos_exposure },
144-
"actions": {
145-
"items": [
146-
{
147-
"href": url('questions:asbestos_exposure', query = change_query_params),
148-
"text": "Change"
149-
}
150-
]
151-
}
152-
},
153-
{
154-
"key": { "text": "Have you ever been diagnosed with cancer?" },
155-
"value": { "text": response_set.cancer_diagnosis },
156-
"actions": {
157-
"items": [
158-
{
159-
"href": url('questions:cancer_diagnosis', query = change_query_params),
160-
"text": "Change"
161-
}
162-
]
163-
}
164-
}
165-
]
30+
"rows": response_set.your_health_responses_items()
16631
}) }}
16732
</section>
16833

lung_cancer_screening/questions/presenters/response_set_presenter.py

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

44
from ..models.education_response import EducationValues
55
from ..models.respiratory_conditions_response import RespiratoryConditionValues
6+
from ..models.family_history_lung_cancer_response import FamilyHistoryLungCancerValues
67

78
class ResponseSetPresenter:
89
DATE_FORMAT = "%-d %B %Y" # eg 8 September 2000
@@ -121,6 +122,75 @@ def respiratory_conditions(self):
121122
])
122123

123124

125+
def eligibility_responses_items(self):
126+
return [
127+
self._check_your_answer_item(
128+
"Have you ever smoked tobacco?",
129+
self.have_you_ever_smoked,
130+
"questions:have_you_ever_smoked",
131+
),
132+
self._check_your_answer_item(
133+
"Date of birth",
134+
self.date_of_birth,
135+
"questions:date_of_birth",
136+
)
137+
]
138+
139+
def about_you_responses_items(self):
140+
return [
141+
self._check_your_answer_item(
142+
"Height",
143+
self.height,
144+
"questions:height",
145+
),
146+
self._check_your_answer_item(
147+
"Weight",
148+
self.weight,
149+
"questions:weight",
150+
),
151+
self._check_your_answer_item(
152+
"Sex at birth",
153+
self.sex_at_birth,
154+
"questions:sex_at_birth",
155+
),
156+
self._check_your_answer_item(
157+
"Gender identity",
158+
self.gender,
159+
"questions:gender",
160+
),
161+
self._check_your_answer_item(
162+
"Ethnic background",
163+
self.ethnicity,
164+
"questions:ethnicity",
165+
),
166+
self._check_your_answer_item(
167+
"Education",
168+
self.education,
169+
"questions:education",
170+
)
171+
]
172+
173+
174+
def your_health_responses_items(self):
175+
return [
176+
self._check_your_answer_item(
177+
"Diagnosed respiratory conditions",
178+
self.respiratory_conditions,
179+
"questions:respiratory_conditions",
180+
),
181+
self._check_your_answer_item(
182+
"Have you ever worked in a job where you were exposed to asbestos?",
183+
self.asbestos_exposure,
184+
"questions:asbestos_exposure",
185+
),
186+
self._check_your_answer_item(
187+
"Have you ever been diagnosed with cancer?",
188+
self.cancer_diagnosis,
189+
"questions:cancer_diagnosis",
190+
)
191+
]
192+
193+
124194
def family_history_responses_items(self):
125195
items = [
126196
self._check_your_answer_item(

0 commit comments

Comments
 (0)