Skip to content

Commit fd1201f

Browse files
authored
Merge pull request #135 from NHSDigital/fix-csrf-sonarqube-issues
Only allow GET and POST requests for views
2 parents f9c3e9a + e190798 commit fd1201f

File tree

11 files changed

+22
-2
lines changed

11 files changed

+22
-2
lines changed

lung_cancer_screening/questions/views/age_range_exit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from django.shortcuts import render
2+
from django.views.decorators.http import require_GET
23

34
from .decorators.participant_decorators import require_participant
45

6+
@require_GET
57
@require_participant
68
def age_range_exit(request):
79
return render(

lung_cancer_screening/questions/views/date_of_birth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
3+
from django.views.decorators.http import require_http_methods
34
from datetime import date
45
from dateutil.relativedelta import relativedelta
56

67
from .decorators.participant_decorators import require_participant
78
from ..forms.date_of_birth_form import DateOfBirthForm
89

10+
@require_http_methods(["GET", "POST"])
911
@require_participant
1012
def date_of_birth(request):
1113
if request.method == "POST":

lung_cancer_screening/questions/views/ethnicity.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
3+
from django.views.decorators.http import require_http_methods
34

45
from .decorators.participant_decorators import require_participant
56
from ..forms.ethnicity_form import EthnicityForm
67

8+
@require_http_methods(["GET", "POST"])
79
@require_participant
810
def ethnicity(request):
911

lung_cancer_screening/questions/views/gender.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
3+
from django.views.decorators.http import require_http_methods
34

45
from .decorators.participant_decorators import require_participant
56
from ..forms.gender_form import GenderForm
67

8+
@require_http_methods(["GET", "POST"])
79
@require_participant
810
def gender(request):
911
if request.method == "POST":

lung_cancer_screening/questions/views/have_you_ever_smoked.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
3+
from django.views.decorators.http import require_http_methods
34

45
from .decorators.participant_decorators import require_participant
56
from ..forms.have_you_ever_smoked_form import HaveYouEverSmokedForm
67
from ..models.response_set import HaveYouEverSmokedValues
78

9+
@require_http_methods(["GET", "POST"])
810
@require_participant
911
def have_you_ever_smoked(request):
1012
if request.method == "POST":

lung_cancer_screening/questions/views/height.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.shortcuts import render, redirect
2+
from django.views.decorators.http import require_http_methods
23

34
from lung_cancer_screening.questions.forms.metric_height_form import MetricHeightForm
45
from lung_cancer_screening.questions.forms.imperial_height_form import ImperialHeightForm
56
from .decorators.participant_decorators import require_participant
67

8+
@require_http_methods(["GET", "POST"])
79
@require_participant
810
def height(request):
911
unit = request.GET.get('unit')

lung_cancer_screening/questions/views/non_smoker_exit.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
from django.shortcuts import render
2+
from django.views.decorators.http import require_GET
23

34
from .decorators.participant_decorators import require_participant
45

6+
@require_GET
57
@require_participant
68
def non_smoker_exit(request):
79
return render(

lung_cancer_screening/questions/views/responses.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
33
from django.utils import timezone
4+
from django.views.decorators.http import require_http_methods
45

56
from .decorators.participant_decorators import require_participant
67

8+
@require_http_methods(["GET", "POST"])
79
@require_participant
810
def responses(request):
911
response_set = request.participant.responseset_set.last()

lung_cancer_screening/questions/views/sex_at_birth.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
3+
from django.views.decorators.http import require_http_methods
34

45
from .decorators.participant_decorators import require_participant
56
from ..forms.sex_at_birth_form import SexAtBirthForm
67

8+
@require_http_methods(["GET", "POST"])
79
@require_participant
810
def sex_at_birth(request):
911
if request.method == "POST":

lung_cancer_screening/questions/views/start.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
from django.shortcuts import render, redirect
22
from django.urls import reverse
33
from django.core.exceptions import ValidationError
4+
from django.views.decorators.http import require_http_methods
45

56
from lung_cancer_screening.questions.models.participant import Participant
67

8+
@require_http_methods(["GET", "POST"])
79
def start(request):
810
if request.method == "POST":
911
try:

0 commit comments

Comments
 (0)