|
2 | 2 |
|
3 | 3 | from django.http import Http404 |
4 | 4 | from django.shortcuts import redirect |
| 5 | +from django.urls import reverse |
5 | 6 | from rules.contrib.views import PermissionRequiredMixin |
6 | 7 |
|
7 | 8 | from manage_breast_screening.auth.models import Permission |
@@ -50,3 +51,40 @@ def dispatch(self, request, *args, **kwargs): |
50 | 51 | pk=appointment.pk, |
51 | 52 | ) |
52 | 53 | 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