Skip to content

Commit 5850ba6

Browse files
committed
PPHA-475: Remove /start path submission in favour of link
1 parent e7d506a commit 5850ba6

File tree

4 files changed

+8
-121
lines changed

4 files changed

+8
-121
lines changed
Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,17 @@
11
{% extends 'layout.jinja' %}
2-
{% from 'nhsuk/components/error-summary/macro.jinja' import errorSummary %}
32
{% from 'nhsuk/components/button/macro.jinja' import button %}
4-
{% from 'nhsuk/components/input/macro.jinja' import input %}
53

64
{% block content %}
7-
8-
{% if error_messages %}
9-
{{ errorSummary({
10-
"titleText": "There is a problem",
11-
"errorList": error_messages
12-
}) }}
13-
{% endif %}
14-
155
<div class="nhsuk-grid-row">
166
<div class="nhsuk-grid-column-two-thirds">
17-
<form action="{{ request.path }}" method="POST">
18-
{{ csrf_input }}
19-
20-
{{ input({
21-
"label": {
22-
"text": "Enter your unique user ID",
23-
"isPageHeading": true
24-
},
25-
"id": "user_id",
26-
"name": "user_id"
27-
}) }}
7+
<h1 class="nhsuk-heading-l">
8+
Lung Cancer Risk Check
9+
</h1>
2810

29-
{{ button({
30-
"text": "Start now"
31-
}) }}
32-
</form>
11+
{{ button({
12+
"text": "Start now",
13+
"href": url("questions:have_you_ever_smoked")
14+
}) }}
3315
</div>
3416
</div>
3517
{% endblock %}

lung_cancer_screening/questions/tests/unit/views/test_start.py

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -12,78 +12,3 @@ def test_get_responds_successfully(self):
1212
response = self.client.get(reverse("questions:start"))
1313

1414
self.assertEqual(response.status_code, 200)
15-
16-
class TestPostStart(TestCase):
17-
def setUp(self):
18-
login_user(self.client)
19-
20-
def test_post_redirects_if_the_user_is_not_logged_in(self):
21-
self.client.logout()
22-
23-
response = self.client.post(
24-
reverse("questions:start"),
25-
{"user_id": "12345"}
26-
)
27-
28-
self.assertRedirects(response, "/oidc/authenticate/?next=/start", fetch_redirect_response=False)
29-
30-
# TODO: Remove response set creation and make endpoints create it themselves if it does not exist
31-
32-
# def test_post_creates_a_new_user_and_response_set(self):
33-
# self.client.post(
34-
# reverse("questions:start"),
35-
# {"user_id": "12345"}
36-
# )
37-
38-
# user = Participant.objects.all().last()
39-
# self.assertEqual(user.unique_id, "12345")
40-
# self.assertEqual(user.responseset_set.count(), 1)
41-
42-
# def test_post_creates_a_new_response_set_if_the_user_already_exists_and_has_no_response_set_submitted_in_the_last_year(self):
43-
# user = UserFactory()
44-
# old_response_set = user.responseset_set.create(
45-
# submitted_at=timezone.now() - relativedelta(days=365)
46-
# )
47-
48-
# self.client.post(
49-
# reverse("questions:start"),
50-
# {"user_id": user.unique_id}
51-
# )
52-
53-
# self.assertEqual(user.responseset_set.count(), 2)
54-
# self.assertNotEqual(user.responseset_set.last().id, old_response_set.id)
55-
56-
# def test_post_shows_an_error_if_a_response_set_was_submitted_within_the_last_year(self):
57-
# user = UserFactory()
58-
# user.responseset_set.create(
59-
# submitted_at=timezone.now() - relativedelta(days=364)
60-
# )
61-
62-
# response = self.client.post(
63-
# reverse("questions:start"),
64-
# {"user_id": user.unique_id}
65-
# )
66-
67-
# self.assertEqual(response.status_code, 422)
68-
# self.assertIn(
69-
# "Responses have already been submitted for this user",
70-
# response.text
71-
# )
72-
73-
74-
# def test_post_redirects_to_the_have_you_ever_smoked_path(self):
75-
# response = self.client.post(
76-
# reverse("questions:start"),
77-
# {"user_id": "12345"}
78-
# )
79-
80-
# self.assertRedirects(response, reverse("questions:have_you_ever_smoked"))
81-
82-
# def test_post_responds_with_422_if_the_user_fails_to_create(self):
83-
# response = self.client.post(
84-
# reverse("questions:start"),
85-
# {"user_id": ""}
86-
# )
87-
88-
# self.assertEqual(response.status_code, 422)
89-
Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
1-
from django.shortcuts import render, redirect
2-
from django.urls import reverse
3-
from django.core.exceptions import ValidationError
4-
from django.contrib.auth.decorators import login_required
5-
from django.utils.decorators import method_decorator
1+
from django.shortcuts import render
62
from django.views import View
73

8-
9-
@method_decorator(login_required, name='post')
104
class StartView(View):
115
def get(self, request):
126
return render(
137
request,
148
"start.jinja"
159
)
16-
17-
def post(self, request):
18-
try:
19-
request.user.responseset_set.create()
20-
21-
return redirect(reverse("questions:have_you_ever_smoked"))
22-
except ValidationError as e:
23-
return render(
24-
request,
25-
"start.jinja",
26-
{"error_messages": [{ "text": message } for message in e.messages ]},
27-
status=422
28-
)

tests/features/cannot_change_answers_after_submission.feature

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ Feature: Participants with submitted responses
55
When I go to "/start"
66
And I click "Start"
77
Then I am on "/start"
8-
And I see an error summary "Responses have already been submitted for this user"

0 commit comments

Comments
 (0)