Skip to content

Commit 1a483a3

Browse files
committed
create a mixin for medical information pages
This defines context that is common to all of them, and back/forward navigation that goes back to the record medical information page.
1 parent b05fb5e commit 1a483a3

File tree

1 file changed

+38
-0
lines changed
  • manage_breast_screening/mammograms/views

1 file changed

+38
-0
lines changed

manage_breast_screening/mammograms/views/mixins.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
from django.http import Http404
44
from django.shortcuts import redirect
5+
from django.urls import reverse
56
from rules.contrib.views import PermissionRequiredMixin
67

78
from manage_breast_screening.auth.models import Permission
@@ -50,3 +51,40 @@ def dispatch(self, request, *args, **kwargs):
5051
pk=appointment.pk,
5152
)
5253
return super().dispatch(request, *args, **kwargs) # type: ignore
54+
55+
56+
class MedicalInformationMixin(InProgressAppointmentMixin):
57+
"""
58+
Mixin for views that hang off the medical information page.
59+
60+
These all follow a similar structure, and have the same onwards / back
61+
navigation.
62+
"""
63+
64+
def get_success_url(self):
65+
return reverse(
66+
"mammograms:record_medical_information", kwargs={"pk": self.appointment.pk}
67+
)
68+
69+
def get_back_link_params(self):
70+
return {
71+
"href": reverse(
72+
"mammograms:record_medical_information",
73+
kwargs={"pk": self.appointment_pk},
74+
),
75+
"text": "Back",
76+
}
77+
78+
def get_context_data(self, **kwargs):
79+
context = super().get_context_data(**kwargs)
80+
participant = self.appointment.participant
81+
82+
context.update(
83+
{
84+
"back_link_params": self.get_back_link_params(),
85+
"caption": participant.full_name,
86+
"participant_first_name": participant.first_name,
87+
},
88+
)
89+
90+
return context

0 commit comments

Comments
 (0)