Skip to content

Commit 87f291f

Browse files
committed
PPHA-403: Update to questionnaire framework
1 parent fd1201f commit 87f291f

24 files changed

+271
-161
lines changed

.devcontainer/devcontainer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{
22
"name": "Ubuntu",
3-
"image": "mcr.microsoft.com/devcontainers/base:noble",
3+
"build": {
4+
"dockerfile": "dockerfile"
5+
},
46
"features": {
57
"ghcr.io/devcontainers/features/docker-in-docker:2": {
68
"moby": true,
@@ -21,11 +23,14 @@
2123
"installOhMyZshConfig": true,
2224
"configureZshAsDefaultShell": true
2325
},
26+
"ghcr.io/devcontainers/features/terraform:1": {},
2427
"ghcr.io/devcontainers-extra/features/zsh-plugins:0": {
2528
"plugins": "zsh-autosuggestions zsh-syntax-highlighting",
2629
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions.git https://github.com/zsh-users/zsh-syntax-highlighting.git"
2730
}
2831
},
32+
"workspaceMount": "source=./,target=/app,type=bind,consistency=cached",
33+
"workspaceFolder": "/app",
2934
"postCreateCommand": "pipx install pre-commit && make config && echo 'export GPG_TTY=$TTY' | cat - ~/.zshrc > temp && mv temp ~/.zshrc",
3035
"mounts": [
3136
"source=${localEnv:HOME}/.gnupg,target=/home/vscode/.gnupg,type=bind,consistency=cached"

.devcontainer/dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM mcr.microsoft.com/devcontainers/base:noble
2+
3+
COPY *.crt /usr/local/share/ca-certificates/
4+
5+
RUN update-ca-certificates

lung_cancer_screening/core/tests/acceptance/test_cannot_change_answers_after_submission.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ def test_cannot_change_responses_once_checked_and_submitted(self):
4646
fill_in_and_submit_sex_at_birth(page, "Male")
4747
fill_in_and_submit_gender(page, "Male")
4848
fill_in_and_submit_ethnicity(page, "White")
49-
49+
page.click("text=Continue")
50+
page.click("text=Continue")
51+
page.click("text=Continue")
52+
page.click("text=Continue")
53+
page.click("text=Continue")
5054
page.click("text=Submit")
5155

5256
page.goto(f"{self.live_server_url}/start")

lung_cancer_screening/core/tests/acceptance/test_questionnaire.py

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,34 @@ def test_full_questionnaire_user_journey(self):
8787

8888
expect(page).to_have_url(f"{self.live_server_url}/ethnicity")
8989
expect_back_link_to_have_url(page, "/gender")
90-
9190
fill_in_and_submit_ethnicity(page, "White")
9291

93-
expect(page).to_have_url(f"{self.live_server_url}/responses")
92+
expect(page).to_have_url(f"{self.live_server_url}/education")
9493
expect_back_link_to_have_url(page, "/ethnicity")
94+
page.click("text=Continue")
95+
96+
expect(page).to_have_url(f"{self.live_server_url}/respiratory-conditions")
97+
expect_back_link_to_have_url(page, "/education")
98+
page.click("text=Continue")
99+
100+
expect(page).to_have_url(f"{self.live_server_url}/asbestos-exposure")
101+
expect_back_link_to_have_url(page, "/respiratory-conditions")
102+
page.click("text=Continue")
103+
104+
expect(page).to_have_url(f"{self.live_server_url}/cancer-diagnosis")
105+
expect_back_link_to_have_url(page, "/asbestos-exposure")
106+
page.click("text=Continue")
107+
108+
expect(page).to_have_url(f"{self.live_server_url}/family-history-lung-cancer")
109+
expect_back_link_to_have_url(page, "/cancer-diagnosis")
110+
page.click("text=Continue")
111+
112+
expect(page).to_have_url(f"{self.live_server_url}/responses")
113+
expect_back_link_to_have_url(page, "/family-history-lung-cancer")
95114

96115
responses = page.locator(".responses")
97116
expect(responses).to_contain_text("Have you ever smoked? Yes, I used to smoke regularly")
98-
expect(responses).to_contain_text(
99-
age.strftime("What is your date of birth? %Y-%m-%d"))
117+
expect(responses).to_contain_text(age.strftime("What is your date of birth? %Y-%m-%d"))
100118
expect(responses).to_contain_text(f"What is your height? {feet} feet {inches} inches")
101119
expect(responses).to_contain_text(f"What is your weight? {weight_stone} stone {weight_pound} pound")
102120
expect(responses).to_contain_text("What was your sex at birth? Male")

lung_cancer_screening/questions/forms/gender_form.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django import forms
22

3-
from ...nhsuk_forms.typed_choice_field import TypedChoiceField
3+
from ...nhsuk_forms.choice_field import ChoiceField
44
from ..models.response_set import ResponseSet, GenderValues
55

66
class GenderForm(forms.ModelForm):
@@ -10,7 +10,7 @@ def __init__(self, *args, **kwargs):
1010
super().__init__(*args, **kwargs)
1111
self.instance.participant = self.participant
1212

13-
self.fields["gender"] = TypedChoiceField(
13+
self.fields["gender"] = ChoiceField(
1414
choices=GenderValues.choices,
1515
widget=forms.RadioSelect,
1616
label="Which of these best describes you?",

lung_cancer_screening/questions/forms/sex_at_birth_form.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from django import forms
22

3-
from ...nhsuk_forms.typed_choice_field import TypedChoiceField
3+
from ...nhsuk_forms.choice_field import ChoiceField
44
from ..models.response_set import ResponseSet, SexAtBirthValues
55

66
class SexAtBirthForm(forms.ModelForm):
@@ -10,7 +10,7 @@ def __init__(self, *args, **kwargs):
1010
super().__init__(*args, **kwargs)
1111
self.instance.participant = self.participant
1212

13-
self.fields["sex_at_birth"] = TypedChoiceField(
13+
self.fields["sex_at_birth"] = ChoiceField(
1414
choices=SexAtBirthValues.choices,
1515
widget=forms.RadioSelect,
1616
label="What was your sex at birth?",

lung_cancer_screening/questions/jinja2/date_of_birth.jinja

Lines changed: 0 additions & 34 deletions
This file was deleted.

lung_cancer_screening/questions/jinja2/gender.jinja

Lines changed: 0 additions & 28 deletions
This file was deleted.

lung_cancer_screening/questions/jinja2/height.jinja

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,50 +4,47 @@
44
{% from 'nhsuk/components/fieldset/macro.jinja' import fieldset %}
55

66
{% block beforeContent %}
7-
{{
8-
backLink({
9-
"href": url("questions:date_of_birth"),
10-
"text": "Back"
11-
})
12-
}}
7+
{{
8+
backLink({
9+
"href": url("questions:date_of_birth"),
10+
"text": "Back"
11+
})
12+
}}
1313
{% endblock beforeContent %}
1414

1515
{% block page_content %}
16-
<div class="nhsuk-grid-row">
17-
<div class="nhsuk-grid-column-two-thirds">
18-
{% if unit %}
19-
{% set action_url = request.path + '?unit=' + unit %}
20-
{% else %}
21-
{% set action_url = request.path %}
22-
{% endif %}
23-
<form action="{{ action_url }}" method="POST" novalidate>
24-
{{ csrf_input }}
25-
<h1 class="nhsuk-heading-l">What is your height?</h1>
26-
<p>An accurate measurement is important.
27-
28-
<p>You can measure your height at home with a measuring tape. Some pharmacies and gyms have machines to measure your height.
16+
<div class="nhsuk-grid-row">
17+
<div class="nhsuk-grid-column-two-thirds">
18+
<form action="{{ request.get_full_path() }}" method="POST" novalidate>
19+
{{ csrf_input }}
20+
<h1 class="nhsuk-heading-l">What is your height?</h1>
21+
<p>An accurate measurement is important.
22+
23+
<p>You can measure your height at home with a measuring tape. Some pharmacies and gyms have machines to measure
24+
your height.
2925
{% call fieldset({
3026
"legend": {
3127
"text": "Enter your height",
3228
"classes": "nhsuk-label--m"
3329
}
34-
}) %}
30+
})
31+
%}
3532

36-
{% if unit == "imperial" %}
37-
{{ form.height_imperial.as_field_group() }}
38-
{% else %}
39-
{{ form.height.as_field_group() }}
40-
{% endif %}
33+
{% if unit == "imperial" %}
34+
{{ form.height_imperial.as_field_group() }}
35+
{% else %}
36+
{{ form.height.as_field_group() }}
37+
{% endif %}
4138

4239

43-
<p><a href="?unit={{ switch_to_unit }}">Switch to {{ switch_to_unit }}</a></p>
40+
<p><a href="?unit={{ switch_to_unit }}">Switch to {{ switch_to_unit }}</a></p>
4441

45-
{% endcall %}
42+
{% endcall %}
4643

47-
{{ button({
48-
"text": "Continue"
49-
}) }}
50-
</form>
51-
</div>
44+
{{ button({
45+
"text": "Continue"
46+
}) }}
47+
</form>
5248
</div>
49+
</div>
5350
{% endblock %}

lung_cancer_screening/questions/jinja2/ethnicity.jinja renamed to lung_cancer_screening/questions/jinja2/question_form.jinja

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
{% extends 'layout.jinja' %}
2+
23
{% from 'nhsuk/components/button/macro.jinja' import button %}
34
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}
45

6+
{% if error %}
7+
{% set error_message = { "text": error } %}
8+
{% endif %}
9+
510
{% block beforeContent %}
611
{{
712
backLink({
8-
"href": url("questions:gender"),
13+
"href": back_link_url,
914
"text": "Back"
1015
})
1116
}}

0 commit comments

Comments
 (0)