Skip to content

Commit 941a7ba

Browse files
authored
PPHA-410 Smoking page content updates (#160)
* Create body of smoking page and update options * Adding have you ever smoked form unit test * Add node to dev-container
1 parent 536fe3b commit 941a7ba

File tree

9 files changed

+53
-33
lines changed

9 files changed

+53
-33
lines changed

.devcontainer/devcontainer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"configureZshAsDefaultShell": true
2525
},
2626
"ghcr.io/devcontainers/features/terraform:1": {},
27+
"ghcr.io/devcontainers/features/node:1": {},
2728
"ghcr.io/devcontainers-extra/features/zsh-plugins:0": {
2829
"plugins": "zsh-autosuggestions zsh-syntax-highlighting",
2930
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions.git https://github.com/zsh-users/zsh-syntax-highlighting.git"

lung_cancer_screening/questions/forms/have_you_ever_smoked_form.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@ def __init__(self, *args, **kwargs):
1515
widget=forms.RadioSelect,
1616
label="Have you ever smoked?",
1717
label_classes="nhsuk-fieldset__legend--m",
18-
label_is_page_heading=True,
19-
coerce=int
18+
hint="This includes social smoking",
19+
coerce=int,
20+
error_messages={
21+
'required': 'Select if you have ever smoked'
22+
}
2023
)
2124

2225
class Meta:
Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,19 @@
1-
{% extends 'layout.jinja' %}
2-
{% from 'nhsuk/components/button/macro.jinja' import button %}
3-
{% from 'nhsuk/components/radios/macro.jinja' import radios %}
4-
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}
1+
{% extends 'question_form.jinja' %}
52

6-
{% block beforeContent %}
7-
{{
8-
backLink({
9-
"href": url("questions:start"),
10-
"text": "Back"
11-
})
12-
}}
13-
{% endblock beforeContent %}
3+
{% block prelude %}
144

15-
{% block content %}
16-
<div class="nhsuk-grid-row">
17-
<div class="nhsuk-grid-column-two-thirds">
18-
<form action="{{ request.path }}" method="POST">
19-
{{ csrf_input }}
5+
<h1 class="nhsuk-heading-l">Tobacco smoking</h1>
206

21-
{{ form.have_you_ever_smoked.as_field_group() }}
7+
<p>We will ask you questions about your smoking habits. This includes different types of tobacco smoking such as:
228

23-
{{ button({
24-
"text": "Continue"
25-
}) }}
26-
</form>
27-
</div>
28-
</div>
29-
{% endblock %}
9+
<ul>
10+
<li>cigarettes from a packet</li>
11+
<li>rolled cigarettes, or roll ups</li>
12+
<li>a pipe</li>
13+
<li>cigars</li>
14+
<li>hookah or shisha</li>
15+
</ul>
16+
17+
<p>It does not currently include vaping or e-cigarettes.
18+
19+
{% endblock prelude %}

lung_cancer_screening/questions/jinja2/question_form.jinja

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
<form action="{{ request.path }}" method="POST">
1414
{{ csrf_input }}
1515

16+
{% block prelude %}
17+
{% endblock%}
18+
1619
{{ form }}
1720

1821
{{ button({

lung_cancer_screening/questions/models/response_set.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
class HaveYouEverSmokedValues(models.IntegerChoices):
1313
YES_I_CURRENTLY_SMOKE = 0, 'Yes, I currently smoke'
14-
YES_I_USED_TO_SMOKE_REGULARLY = 1, 'Yes, I used to smoke regularly'
15-
YES_BUT_ONLY_A_FEW_TIMES = 2, 'Yes, but only a few times'
14+
YES_I_USED_TO_SMOKE_REGULARLY = 1, 'Yes, I used to smoke'
15+
YES_BUT_ONLY_A_FEW_TIMES = 2, 'Yes, but I have smoked fewer than 100 cigarettes in my lifetime'
1616
NO_I_HAVE_NEVER_SMOKED = 3, 'No, I have never smoked'
1717

1818
class SexAtBirthValues(models.TextChoices):

lung_cancer_screening/questions/tests/unit/forms/test_have_you_ever_smoked_form.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,23 @@ def test_is_invalid(self):
2525
}
2626
)
2727
self.assertFalse(form.is_valid())
28+
self.assertEqual(
29+
form.errors["have_you_ever_smoked"],
30+
["Select a valid choice. invalid is not one of the available choices."]
31+
)
32+
33+
def test_is_invalid_when_no_option_is_selected(self):
34+
form = HaveYouEverSmokedForm(
35+
participant=self.participant,
36+
data={
37+
"have_you_ever_smoked": None
38+
}
39+
)
40+
self.assertFalse(form.is_valid())
41+
self.assertEqual(
42+
form.errors["have_you_ever_smoked"],
43+
["Select if you have ever smoked"]
44+
)
2845

2946
def test_returns_a_boolean_type(self):
3047
form = HaveYouEverSmokedForm(

lung_cancer_screening/questions/views/have_you_ever_smoked.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ def post(self, request):
4040
status=422
4141
)
4242

43-
4443
def render_template(request, form, status=200):
4544
return render(
4645
request,
47-
"question_form.jinja",
46+
"have_you_ever_smoked.jinja",
4847
{
4948
"form": form,
5049
"back_link_url": reverse("questions:start")

tests/features/questionnaire.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Feature: Questionnaire
44
And I submit my participant id
55
Then I am on "/have-you-ever-smoked"
66
And I see a back link to "/start"
7-
When I fill in and submit my smoking status with "Yes, I used to smoke regularly"
7+
When I fill in and submit my smoking status with "Yes, I used to smoke"
88
Then I am on "/date-of-birth"
99
And I see a back link to "/have-you-ever-smoked"
1010
When I fill in and submit my date of birth as 55 years ago
@@ -46,7 +46,7 @@ Feature: Questionnaire
4646
When I click "Continue"
4747
Then I am on "/responses"
4848
And I see a back link to "/family-history-lung-cancer"
49-
And I see responses "Have you ever smoked? Yes, I used to smoke regularly"
49+
And I see responses "Have you ever smoked? Yes, I used to smoke"
5050
And I see responses "What is your date of birth?" with a date 55 years ago
5151
And I see responses "What is your height? 5 feet 7 inches"
5252
And I see responses "What is your weight? 5 stone 10 pounds"

tests/features/validation_errors.feature

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ Feature: Validation errors
1515
Then I am on "/date-of-birth"
1616
And I see a form error "Date of birth must be a real date"
1717

18+
Scenario: Have you ever smoked form errors
19+
Given I have started the questionnaire
20+
When I go to "/have-you-ever-smoked"
21+
And I submit the form
22+
Then I am on "/have-you-ever-smoked"
23+
And I see a form error "Select if you have ever smoked"
24+
1825
Scenario: Height form errors
1926
Given I have started the questionnaire
2027
When I go to "/height"

0 commit comments

Comments
 (0)