Skip to content

Commit 010b38b

Browse files
committed
Change to class based views
1 parent 2e4e59b commit 010b38b

File tree

5 files changed

+40
-40
lines changed

5 files changed

+40
-40
lines changed

lung_cancer_screening/questions/views/asbestos_exposure.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
from django.urls import reverse
33

44
from .decorators.participant_decorators import require_participant
5-
from django.views.decorators.http import require_http_methods
5+
from django.views import View
6+
from django.utils.decorators import method_decorator
67

7-
@require_http_methods(["GET", "POST"])
8-
@require_participant
9-
def asbestos_exposure(request):
10-
if request.method == "POST":
8+
@method_decorator(require_participant, name="dispatch")
9+
class AsbestosExposureView(View):
10+
def get(self, request):
11+
return render_template(request)
12+
13+
def post(self, request):
1114
return redirect(reverse("questions:cancer_diagnosis"))
12-
return render_template(
13-
request
14-
)
1515

1616
def render_template(request, status=200):
1717
return render(

lung_cancer_screening/questions/views/cancer_diagnosis.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
from django.urls import reverse
33

44
from .decorators.participant_decorators import require_participant
5-
from django.views.decorators.http import require_http_methods
5+
from django.views import View
6+
from django.utils.decorators import method_decorator
67

7-
@require_http_methods(["GET", "POST"])
8-
@require_participant
9-
def cancer_diagnosis(request):
10-
if request.method == "POST":
8+
@method_decorator(require_participant, name="dispatch")
9+
class CancerDiagnosisView(View):
10+
def get(self, request):
11+
return render_template(request)
12+
13+
def post(self, request):
1114
return redirect(reverse("questions:family_history_lung_cancer"))
12-
return render_template(
13-
request
14-
)
1515

1616
def render_template(request, status=200):
1717
return render(

lung_cancer_screening/questions/views/education.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
from django.urls import reverse
33

44
from .decorators.participant_decorators import require_participant
5-
from django.views.decorators.http import require_http_methods
5+
from django.views import View
6+
from django.utils.decorators import method_decorator
67

7-
@require_http_methods(["GET", "POST"])
8-
@require_participant
9-
def education(request):
10-
if request.method == "POST":
8+
@method_decorator(require_participant, name="dispatch")
9+
class EducationView(View):
10+
def get(self, request):
11+
return render_template(request)
12+
13+
def post(self, request):
1114
return redirect(reverse("questions:respiratory_conditions"))
12-
return render_template(
13-
request
14-
)
1515

1616
def render_template(request, status=200):
1717
return render(

lung_cancer_screening/questions/views/family_history_lung_cancer.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
from django.urls import reverse
33

44
from .decorators.participant_decorators import require_participant
5-
from django.views.decorators.http import require_http_methods
5+
from django.views import View
6+
from django.utils.decorators import method_decorator
67

7-
@require_http_methods(["GET", "POST"])
8-
@require_participant
9-
def family_history_lung_cancer(request):
10-
if request.method == "POST":
8+
@method_decorator(require_participant, name="dispatch")
9+
class FamilyHistoryLungCancerView(View):
10+
def get(self, request):
11+
return render_template(request)
12+
13+
def post(self, request):
1114
return redirect(reverse("questions:responses"))
12-
return render_template(
13-
request
14-
)
1515

1616
def render_template(request, status=200):
1717
return render(

lung_cancer_screening/questions/views/respiratory_conditions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
from django.urls import reverse
33

44
from .decorators.participant_decorators import require_participant
5-
from django.views.decorators.http import require_http_methods
5+
from django.views import View
6+
from django.utils.decorators import method_decorator
67

7-
@require_http_methods(["GET", "POST"])
8-
@require_participant
9-
def respiratory_conditions(request):
10-
if request.method == "POST":
8+
@method_decorator(require_participant, name="dispatch")
9+
class RespiratoryConditionsView(View):
10+
def get(self, request):
11+
return render_template(request)
12+
13+
def post(self, request):
1114
return redirect(reverse("questions:asbestos_exposure"))
12-
return render_template(
13-
request
14-
)
1515

1616
def render_template(request, status=200):
1717
return render(

0 commit comments

Comments
 (0)