Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions features/agree_terms_of_use.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@TermsOfUse
Feature: Check if you need an appointment page
Scenario: The page is accessible
Given I am logged in
When I go to "/agree-terms-of-use"
Then there are no accessibility violations

Scenario: Form errors
Given I am logged in
When I go to "/agree-terms-of-use"
And I click "Continue"
Then I am on "/agree-terms-of-use"
And I see a form error "Agree to the terms of use to continue"
And there are no accessibility violations

Scenario: Navigating backwards and forwards
Given I am logged in
When I go to "/agree-terms-of-use"
Then I see a back link to "/start"
When I check "I agree" and submit
Then I am on "/have-you-ever-smoked"
2 changes: 1 addition & 1 deletion features/asbestos_exposure.feature
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,4 @@ Feature: Asbestos exposure page
Scenario: Cannot answer when ineligible
Given I am logged in
When I go to "/asbestos-exposure"
Then I am on "/have-you-ever-smoked"
Then I am on "/agree-terms-of-use"
4 changes: 4 additions & 0 deletions features/check_need_appointment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Feature: Check if you need an appointment page

Scenario: Form errors
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
And I have answered date of birth with an eligible date of birth
When I go to "/check-if-you-need-an-appointment"
Expand All @@ -19,6 +20,7 @@ Feature: Check if you need an appointment page

Scenario: Eligibility exit if needs face to face appointment
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
And I have answered date of birth with an eligible date of birth
When I go to "/check-if-you-need-an-appointment"
Expand All @@ -28,6 +30,7 @@ Feature: Check if you need an appointment page

Scenario: Navigating backwards and forwards
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
And I have answered date of birth with an eligible date of birth
When I go to "/check-if-you-need-an-appointment"
Expand All @@ -37,6 +40,7 @@ Feature: Check if you need an appointment page

Scenario: Checking responses and changing them
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
And I have answered date of birth with an eligible date of birth
When I go to "/check-if-you-need-an-appointment"
Expand Down
3 changes: 3 additions & 0 deletions features/date_of_birth_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Feature: Date of birth page

Scenario: Form errors
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
When I go to "/date-of-birth"
When I click "Continue"
Expand All @@ -26,6 +27,7 @@ Feature: Date of birth page

Scenario: Eligibility of people not in age range
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
When I go to "/date-of-birth"
And I fill in and submit my date of birth with "01-01-1900"
Expand All @@ -34,6 +36,7 @@ Feature: Date of birth page

Scenario: Navigating backwards and forwards
Given I am logged in
And I have answered questions showing I have accepted the terms of use
And I have answered have you ever smoked with an eligible response
When I go to "/date-of-birth"
Then I see a back link to "/have-you-ever-smoked"
Expand Down
5 changes: 4 additions & 1 deletion features/have_you_ever_smoked_page.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Feature: Have you ever smoked page

Scenario: Form errors
Given I am logged in
And I have answered questions showing I have accepted the terms of use
When I go to "/have-you-ever-smoked"
And I submit the form
Then I am on "/have-you-ever-smoked"
Expand All @@ -15,6 +16,7 @@ Feature: Have you ever smoked page

Scenario: Eligibility of non smokers
Given I am logged in
And I have answered questions showing I have accepted the terms of use
When I go to "/have-you-ever-smoked"
And I fill in and submit my smoking status with "No, I have never smoked"
Then I am on "/non-smoker-exit"
Expand All @@ -23,8 +25,9 @@ Feature: Have you ever smoked page

Scenario: Navigating backwards and forwards
Given I am logged in
And I have answered questions showing I have accepted the terms of use
When I go to "/have-you-ever-smoked"
Then I see a back link to "/start"
Then I see a back link to "/agree-terms-of-use"
When I fill in and submit my smoking status with "Yes, I used to smoke"
Then I am on "/date-of-birth"

Expand Down
3 changes: 3 additions & 0 deletions features/questionnaire.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ Feature: Questionnaire
When I go to "/start"
And I click "Continue"

Then I am on "/agree-terms-of-use"
When I check "I agree" and submit

Then I am on "/have-you-ever-smoked"
When I fill in and submit my smoking status with "Yes, I used to smoke"

Expand Down
9 changes: 9 additions & 0 deletions features/steps/preflight_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from lung_cancer_screening.questions.tests.factories.age_when_started_smoking_response_factory import (
AgeWhenStartedSmokingResponseFactory,
)
from lung_cancer_screening.questions.tests.factories.terms_of_use_response_factory import TermsOfUseResponseFactory


def get_or_create_response_set(context):
Expand All @@ -32,6 +33,14 @@ def get_or_create_response_set(context):
)
)

@given("I have answered questions showing I have accepted the terms of use")
def given_i_have_answered_questions_showing_i_have_accepted_the_terms_of_use(context):
response_set = get_or_create_response_set(context)

TermsOfUseResponseFactory.create(
response_set=response_set,
value=True,
)

@given('I have answered have you ever smoked with an eligible response')
def given_i_have_answered_have_your_ever_smoked_with_an_eligible_response(context):
Expand Down
14 changes: 14 additions & 0 deletions lung_cancer_screening/assets/sass/components/_numbered_lists.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
body {
counter-reset: chapter; /* Create a chapter counter scope */
}
.numbered h2:before {
content: counter(chapter) ". ";
counter-increment: chapter; /* Add 1 to chapter */
}
.numbered ol { counter-reset: section }
.numbered ol > li { display: block }
.numbered ol > li:before {
content: counter(chapter) "." counter(section) ". ";
counter-increment: section;
font-weight: 600;
}
2 changes: 2 additions & 0 deletions lung_cancer_screening/assets/sass/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@

// Components that are not in the NHS.UK frontend library
@forward "components/multi_field_input";

@forward "components/numbered_lists"
6 changes: 5 additions & 1 deletion lung_cancer_screening/core/jinja2/layout.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@
{
"href": url("questions:privacy_policy"),
"text": "Privacy policy"
}
},
{
"href": url("questions:terms_of_use"),
"text": "Terms of use"
},
]
}
}) }}
Expand Down
10 changes: 7 additions & 3 deletions lung_cancer_screening/jinja2_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ def environment(**options):
{"singularize": singularize}
)

env.filters.update(
{"singularize": singularize}
)
env.filters['print'] = lambda x: ""
if (settings.DEBUG):
env.filters['print']=debug

return env

def debug(text):
print(text)
return ''
1 change: 0 additions & 1 deletion lung_cancer_screening/nhsuk_forms/choice_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ def _template_name(widget):
) or isinstance(widget, widgets.Select):
return "select.jinja"


class MultipleChoiceField(forms.MultipleChoiceField):
"""
A MultipleChoiceField that renders using the NHS.UK design system checkboxes
Expand Down
3 changes: 2 additions & 1 deletion lung_cancer_screening/nhsuk_forms/jinja2/checkboxes.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
{% set ns = namespace(items=[]) %}
{% for value, text in unbound_field.choices %}
{% set hint_text = field.get_hint_for_choice(value) %}
{% set checked = (value in (field.value() or [])) if (field.value() is iterable) else (value == field.value()) %}
{% set ns.items = ns.items + [{
"id": field.auto_id ~ '_' ~ loop.index0,
"value": value,
"text": text,
"checked": value in (field.value() or []),
"checked": checked,
"hint": {
"text": hint_text
} if hint_text else undefined
Expand Down
28 changes: 28 additions & 0 deletions lung_cancer_screening/questions/forms/agree_terms_of_use_form.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django import forms

from ...nhsuk_forms.choice_field import MultipleChoiceField

from ..models.terms_of_use_response import TermsOfUseResponse


class TermsOfUseForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields["value"] = MultipleChoiceField(
choices=[(True, 'I agree')],
widget=forms.CheckboxSelectMultiple,
label="Accept terms of use",
label_classes="nhsuk-u-visually-hidden",
error_messages={
"required": "Agree to the terms of use to continue",

Check failure on line 17 in lung_cancer_screening/questions/forms/agree_terms_of_use_form.py

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Define a constant instead of duplicating this literal "Agree to the terms of use to continue" 3 times.

See more on https://sonarcloud.io/project/issues?id=NHSDigital_lung_cancer_screening&issues=AZz1wEElxoEI8wj8gjUI&open=AZz1wEElxoEI8wj8gjUI&pullRequest=357
"invalid_choice": "Agree to the terms of use to continue",
"invalid_list": "Agree to the terms of use to continue"
}
)
class Meta:
model = TermsOfUseResponse
fields = ["value"]

def clean_value(self):
values = self.cleaned_data.get("value") or []
return "True" in values
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% extends 'question_form.jinja' %}

{% block prelude %}
<h1 class="nhsuk-heading-l">Accept terms of use</h1>

<p>To continue, confirm that you have read and agree to the <a href="/terms-of-use" target="_blank">NHS Check if you need a lung scan terms of use (opens in new tab)</a></p>
{% endblock %}
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/jinja2/start.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

{{ button({
"text": "Continue",
"href": url("questions:have_you_ever_smoked"),
"href": url("questions:agree_terms_of_use"),
"classes": "nhsuk-button--login"
}) }}

Expand Down
Loading
Loading