-
Notifications
You must be signed in to change notification settings - Fork 2
PPHA-593: separate quit smoking page from periods you stopped smoking #427
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
6fc79bb
PPHA-593: First pass WhenYouQuitSmoking page
Themitchell 7686db2
PPHA-593: Add quit smoking prelude text to match figma
Themitchell 9baa911
PPHA-593: Rename EnsurePrerequisiteResponses to EnsureSmokingHistoryP…
Themitchell fff387c
PPHA-593: Redirect age quit to age started smoking when unanswered
Themitchell 250bca2
PPHA-593: Ensure users can change answers to quit smoking
Themitchell 937fe56
PPHA-593: Only former smoker is asked when they quit
Themitchell 69b798a
PPHA-593: Ensure quit smoking must be answered for former smokers
Themitchell 012d759
PPHA-593: Add correct back links for quit smoking
Themitchell 38cc329
PPHA-593: Ensure quit page cannot be accessed for current smokers
Themitchell 66fe084
Clear quit response and more validation
jamiefalcus 474543c
Fix to validation error message for former smoker
jamiefalcus e9d48ab
Correct current with former and max age validation
jamiefalcus c308328
Fix broken tests that needed current smoker
jamiefalcus 73bdfab
Test fixes
jamiefalcus 1d7e5b0
Correct deletion of when you quit smoking cause
jamiefalcus 0c6b2c6
Remove a wip tag
jamiefalcus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| @SmokingHistory | ||
| @WhenYouQuitSmoking | ||
| Feature: Age quit smoking | ||
| Scenario: The page is accessible | ||
| Given I am logged in | ||
| And I have answered questions showing I am eligible | ||
| And I have answered questions showing I am a former smoker | ||
| And I am 60 years old | ||
| And I have answered questions showing I started smoking "30" years ago | ||
| When I go to "/age-when-started-smoking" | ||
| Then there are no accessibility violations | ||
|
|
||
| Scenario: Form errors | ||
| Given I am logged in | ||
| And I have answered questions showing I am eligible | ||
| And I have answered questions showing I am a former smoker | ||
| And I am 60 years old | ||
| And I have answered questions showing I started smoking "30" years ago | ||
| When I go to "/when-you-quit-smoking" | ||
| And I click "Continue" | ||
| Then I am on "/when-you-quit-smoking" | ||
| And I see a form error "Enter your age when you quit smoking" | ||
| And there are no accessibility violations | ||
|
|
||
| Scenario: Navigating backwards and forwards | ||
| Given I am logged in | ||
| And I have answered questions showing I am eligible | ||
| And I have answered questions showing I am a former smoker | ||
| And I am 60 years old | ||
| And I have answered questions showing I started smoking "30" years ago | ||
| When I go to "/when-you-quit-smoking" | ||
| Then I see a back link to "/age-when-started-smoking" | ||
| When I fill in "How old were you when you quit smoking?" as "30" and submit | ||
| Then I am on "/periods-when-you-stopped-smoking" | ||
|
|
||
| Scenario: Checking responses and changing them | ||
| Given I am logged in | ||
| And I have answered questions showing I am eligible | ||
| And I have answered questions showing I am a former smoker | ||
| And I am 60 years old | ||
| And I have answered questions showing I started smoking "30" years ago | ||
| When I go to "/when-you-quit-smoking" | ||
| And I fill in "How old were you when you quit smoking?" as "40" and submit | ||
| When I go to "/check-your-answers" | ||
| Then I see "40" as a response to "Age you quit smoking" under "Smoking history" | ||
| And I see "/when-you-quit-smoking?change=True" as a link to change "Age you quit smoking" under "Smoking history" | ||
| When I click the link to change "Age you quit smoking" under "Smoking History" | ||
| Then I am on "/when-you-quit-smoking?change=True" | ||
| And I see "40" filled in for "How old were you when you quit smoking?" | ||
| When I fill in "How old were you when you quit smoking?" as "45" and submit | ||
| Then I am on "/periods-when-you-stopped-smoking?change=True" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
lung_cancer_screening/questions/forms/when_you_quit_smoking_form.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| from django import forms | ||
| from django.urls import reverse_lazy | ||
| from django.utils.html import format_html | ||
|
|
||
| from lung_cancer_screening.nhsuk_forms.integer_field import IntegerField | ||
| from ..models.when_you_quit_smoking_response import WhenYouQuitSmokingResponse | ||
|
|
||
| class WhenYouQuitSmokingForm(forms.ModelForm): | ||
| class Meta: | ||
| model = WhenYouQuitSmokingResponse | ||
| fields = ["value"] | ||
|
|
||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
|
|
||
| self.fields["value"] = IntegerField( | ||
| label="How old were you when you quit smoking?", | ||
| label_classes="nhsuk-label--m", | ||
| classes="nhsuk-input--width-2", | ||
| hint="Give an estimate if you are not sure", | ||
| prefix="Age", | ||
| error_messages={ | ||
| "required": "Enter your age when you quit smoking", | ||
| "invalid": "Enter your age when you quit smoking", | ||
| "min_value":"The age you quit smoking must be between 1 and your current age", | ||
| "age_when_quit_smoking_greater_than_age_started":"The age you quit smoking cannot be lower than the age you started smoking", | ||
|
jamiefalcus marked this conversation as resolved.
|
||
| "age_when_quit_smoking_greater_than_current_age" : "The age you quit smoking must be the same as, or less than, your current age", | ||
| "no_date_of_birth" : format_html("<a href=\"{}\">Provide your date of birth</a> before answering when you quit smoking", reverse_lazy("questions:date_of_birth")) | ||
| } | ||
| ) | ||
11 changes: 11 additions & 0 deletions
11
lung_cancer_screening/questions/jinja2/when_you_quit_smoking.jinja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| {% extends 'question_form.jinja' %} | ||
|
|
||
| {% block pageTitle %}When did you quit smoking? – Check if you need a lung scan – NHS{% endblock %} | ||
|
|
||
| {% block prelude %} | ||
| <h1 class="nhsuk-heading-l">When you quit smoking?</h1> | ||
|
jamiefalcus marked this conversation as resolved.
|
||
|
|
||
| <p>If you stopped smoking more than once, tell us your age when you last quit smoking.</p> | ||
|
|
||
| <p>The question on the next page will ask if you ever stopped smoking for periods of 1 year or longer before you quit.</p> | ||
| {% endblock prelude %} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.