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
7 changes: 6 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "Ubuntu",
"image": "mcr.microsoft.com/devcontainers/base:noble",
"build": {
"dockerfile": "dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {
"moby": true,
Expand All @@ -21,11 +23,14 @@
"installOhMyZshConfig": true,
"configureZshAsDefaultShell": true
},
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers-extra/features/zsh-plugins:0": {
"plugins": "zsh-autosuggestions zsh-syntax-highlighting",
"omzPlugins": "https://github.com/zsh-users/zsh-autosuggestions.git https://github.com/zsh-users/zsh-syntax-highlighting.git"
}
},
"workspaceMount": "source=./,target=/app,type=bind,consistency=cached",
"workspaceFolder": "/app",
"postCreateCommand": "pipx install pre-commit && make config && echo 'export GPG_TTY=$TTY' | cat - ~/.zshrc > temp && mv temp ~/.zshrc",
"mounts": [
"source=${localEnv:HOME}/.gnupg,target=/home/vscode/.gnupg,type=bind,consistency=cached"
Expand Down
5 changes: 5 additions & 0 deletions .devcontainer/dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM mcr.microsoft.com/devcontainers/base:noble

COPY *.crt /usr/local/share/ca-certificates/

RUN update-ca-certificates
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ lung_cancer_screening/assets/compiled/*
!lung_cancer_screening/assets/compiled/.gitkeep
.DS_Store
.venv
.devcontainer/ca.crt
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def test_cannot_change_responses_once_checked_and_submitted(self):
fill_in_and_submit_sex_at_birth(page, "Male")
fill_in_and_submit_gender(page, "Male")
fill_in_and_submit_ethnicity(page, "White")
page.click("text=Continue") # education
page.click("text=Continue") # respiratory conditions
fill_in_and_submit_asbestos_exposure(page, "No")

page.click("text=Continue") # cancer diagnosis
page.click("text=Continue") # family history
page.click("text=Submit")

page.goto(f"{self.live_server_url}/start")
Expand Down
23 changes: 18 additions & 5 deletions lung_cancer_screening/core/tests/acceptance/test_questionnaire.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,34 @@ def test_full_questionnaire_user_journey(self):

expect(page).to_have_url(f"{self.live_server_url}/ethnicity")
expect_back_link_to_have_url(page, "/gender")

fill_in_and_submit_ethnicity(page, "White")

expect(page).to_have_url(f"{self.live_server_url}/asbestos-exposure")
expect(page).to_have_url(f"{self.live_server_url}/education")
expect_back_link_to_have_url(page, "/ethnicity")
page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/respiratory-conditions")
expect_back_link_to_have_url(page, "/education")
page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/asbestos-exposure")
expect_back_link_to_have_url(page, "/respiratory-conditions")
fill_in_and_submit_asbestos_exposure(page, "No")

expect(page).to_have_url(f"{self.live_server_url}/responses")
expect(page).to_have_url(f"{self.live_server_url}/cancer-diagnosis")
expect_back_link_to_have_url(page, "/asbestos-exposure")
page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/family-history-lung-cancer")
expect_back_link_to_have_url(page, "/cancer-diagnosis")
page.click("text=Continue")

expect(page).to_have_url(f"{self.live_server_url}/responses")
expect_back_link_to_have_url(page, "/family-history-lung-cancer")

responses = page.locator(".responses")
expect(responses).to_contain_text("Have you ever smoked? Yes, I used to smoke regularly")
expect(responses).to_contain_text(
age.strftime("What is your date of birth? %Y-%m-%d"))
expect(responses).to_contain_text(age.strftime("What is your date of birth? %Y-%m-%d"))
expect(responses).to_contain_text(f"What is your height? {feet} feet {inches} inches")
expect(responses).to_contain_text(f"What is your weight? {weight_stone} stone {weight_pound} pound")
expect(responses).to_contain_text("What was your sex at birth? Male")
Expand Down
4 changes: 2 additions & 2 deletions lung_cancer_screening/questions/forms/gender_form.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms

from ...nhsuk_forms.typed_choice_field import TypedChoiceField
from ...nhsuk_forms.choice_field import ChoiceField
from ..models.response_set import ResponseSet, GenderValues

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

self.fields["gender"] = TypedChoiceField(
self.fields["gender"] = ChoiceField(
choices=GenderValues.choices,
widget=forms.RadioSelect,
label="Which of these best describes you?",
Expand Down
4 changes: 2 additions & 2 deletions lung_cancer_screening/questions/forms/sex_at_birth_form.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms

from ...nhsuk_forms.typed_choice_field import TypedChoiceField
from ...nhsuk_forms.choice_field import ChoiceField
from ..models.response_set import ResponseSet, SexAtBirthValues

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

self.fields["sex_at_birth"] = TypedChoiceField(
self.fields["sex_at_birth"] = ChoiceField(
choices=SexAtBirthValues.choices,
widget=forms.RadioSelect,
label="What was your sex at birth?",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% block beforeContent %}
{{
backLink({
"href": url("questions:ethnicity"),
"href": url("questions:respiratory_conditions"),
"text": "Back"
})
}}
Expand Down
34 changes: 0 additions & 34 deletions lung_cancer_screening/questions/jinja2/date_of_birth.jinja

This file was deleted.

28 changes: 0 additions & 28 deletions lung_cancer_screening/questions/jinja2/gender.jinja

This file was deleted.

61 changes: 29 additions & 32 deletions lung_cancer_screening/questions/jinja2/height.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,47 @@
{% from 'nhsuk/components/fieldset/macro.jinja' import fieldset %}

{% block beforeContent %}
{{
backLink({
"href": url("questions:date_of_birth"),
"text": "Back"
})
}}
{{
backLink({
"href": url("questions:date_of_birth"),
"text": "Back"
})
}}
{% endblock beforeContent %}

{% block page_content %}
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
{% if unit %}
{% set action_url = request.path + '?unit=' + unit %}
{% else %}
{% set action_url = request.path %}
{% endif %}
<form action="{{ action_url }}" method="POST" novalidate>
{{ csrf_input }}
<h1 class="nhsuk-heading-l">What is your height?</h1>
<p>An accurate measurement is important.

<p>You can measure your height at home with a measuring tape. Some pharmacies and gyms have machines to measure your height.
<div class="nhsuk-grid-row">
<div class="nhsuk-grid-column-two-thirds">
<form action="{{ request.get_full_path() }}" method="POST" novalidate>
{{ csrf_input }}
<h1 class="nhsuk-heading-l">What is your height?</h1>
<p>An accurate measurement is important.

<p>You can measure your height at home with a measuring tape. Some pharmacies and gyms have machines to measure
your height.
{% call fieldset({
"legend": {
"text": "Enter your height",
"classes": "nhsuk-label--m"
}
}) %}
})
%}

{% if unit == "imperial" %}
{{ form.height_imperial.as_field_group() }}
{% else %}
{{ form.height.as_field_group() }}
{% endif %}
{% if unit == "imperial" %}
{{ form.height_imperial.as_field_group() }}
{% else %}
{{ form.height.as_field_group() }}
{% endif %}


<p><a href="?unit={{ switch_to_unit }}">Switch to {{ switch_to_unit }}</a></p>
<p><a href="?unit={{ switch_to_unit }}">Switch to {{ switch_to_unit }}</a></p>

{% endcall %}
{% endcall %}

{{ button({
"text": "Continue"
}) }}
</form>
</div>
{{ button({
"text": "Continue"
}) }}
</form>
</div>
</div>
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{% extends 'layout.jinja' %}

{% from 'nhsuk/components/button/macro.jinja' import button %}
{% from 'nhsuk/components/back-link/macro.jinja' import backLink %}

{% if error %}
{% set error_message = { "text": error } %}
{% endif %}

{% block beforeContent %}
{{
backLink({
"href": url("questions:gender"),
"href": back_link_url,
"text": "Back"
})
}}
Expand Down
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/jinja2/responses.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% block beforeContent %}
{{
backLink({
"href": url("questions:asbestos_exposure"),
"href": url("questions:family_history_lung_cancer"),
"text": "Back"
})
}}
Expand Down
28 changes: 0 additions & 28 deletions lung_cancer_screening/questions/jinja2/sex_at_birth.jinja

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def test_post_redirects_to_the_asbestos_exposure_path(self):
self.valid_params
)

self.assertRedirects(response, reverse("questions:asbestos_exposure"))
self.assertRedirects(response, reverse("questions:education"))

def test_post_responds_with_422_if_the_date_response_fails_to_create(self):
response = self.client.post(
Expand Down
8 changes: 8 additions & 0 deletions lung_cancer_screening/questions/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
from .views.sex_at_birth import sex_at_birth
from .views.gender import gender
from .views.ethnicity import ethnicity
from .views.education import EducationView
from .views.respiratory_conditions import RespiratoryConditionsView
from .views.asbestos_exposure import AsbestosExposureView
from .views.cancer_diagnosis import CancerDiagnosisView
from .views.family_history_lung_cancer import FamilyHistoryLungCancerView

urlpatterns = [
path('start', start, name='start'),
Expand All @@ -38,7 +42,11 @@
path('sex-at-birth', sex_at_birth, name='sex_at_birth'),
path('gender', gender, name='gender'),
path('ethnicity', ethnicity, name='ethnicity'),
path('education', EducationView.as_view(), name='education'),
path('respiratory-conditions', RespiratoryConditionsView.as_view(), name='respiratory_conditions'),
path('asbestos-exposure', AsbestosExposureView.as_view(), name='asbestos_exposure'),
path('cancer-diagnosis', CancerDiagnosisView.as_view(), name='cancer_diagnosis'),
path('family-history-lung-cancer', FamilyHistoryLungCancerView.as_view(), name='family_history_lung_cancer'),
path('responses', responses, name='responses'),
path('age-range-exit', age_range_exit, name='age_range_exit'),
path('non-smoker-exit', non_smoker_exit, name='non_smoker_exit'),
Expand Down
2 changes: 1 addition & 1 deletion lung_cancer_screening/questions/views/asbestos_exposure.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def post(self, request):
response_set = request.participant.responseset_set.last()
response_set.asbestos_exposure = form.cleaned_data["asbestos_exposure"]
response_set.save()
return redirect(reverse("questions:responses"))
return redirect(reverse("questions:cancer_diagnosis"))
else:
return render(
request,
Expand Down
24 changes: 24 additions & 0 deletions lung_cancer_screening/questions/views/cancer_diagnosis.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.shortcuts import render, redirect
from django.urls import reverse

from .decorators.participant_decorators import require_participant
from django.views import View
from django.utils.decorators import method_decorator

@method_decorator(require_participant, name="dispatch")
class CancerDiagnosisView(View):
def get(self, request):
return render_template(request)

def post(self, request):
return redirect(reverse("questions:family_history_lung_cancer"))

def render_template(request, status=200):
return render(
request,
"question_form.jinja",
{
"back_link_url": reverse("questions:asbestos_exposure")
},
status=status
)
Loading
Loading