|
14 | 14 | RecordMedicalInformationForm, |
15 | 15 | ScreeningAppointmentForm, |
16 | 16 | ) |
17 | | -from manage_breast_screening.clinics.models import Appointment |
18 | 17 |
|
19 | 18 | Status = Appointment.Status |
20 | 19 |
|
@@ -88,56 +87,80 @@ def form_valid(self, form): |
88 | 87 | form.save() |
89 | 88 |
|
90 | 89 | if form.cleaned_data["decision"] == "continue": |
91 | | - return redirect("record_a_mammogram:ask_for_medical_information") |
| 90 | + return redirect( |
| 91 | + "record_a_mammogram:ask_for_medical_information", |
| 92 | + id=self.get_appointment().pk, |
| 93 | + ) |
92 | 94 | else: |
93 | | - return redirect("record_a_mammogram:appointment_cannot_go_ahead", id=self.get_appointment().pk) |
| 95 | + return redirect( |
| 96 | + "record_a_mammogram:appointment_cannot_go_ahead", |
| 97 | + id=self.get_appointment().pk, |
| 98 | + ) |
94 | 99 |
|
95 | 100 |
|
96 | 101 | class AskForMedicalInformation(FormView): |
97 | 102 | template_name = "record_a_mammogram/ask_for_medical_information.jinja" |
98 | 103 | form_class = AskForMedicalInformationForm |
99 | 104 |
|
| 105 | + def get_appointment(self): |
| 106 | + id = self.kwargs["id"] |
| 107 | + |
| 108 | + return Appointment.objects.get(pk=id) |
| 109 | + |
100 | 110 | def form_valid(self, form): |
101 | 111 | form.save() |
102 | 112 |
|
| 113 | + appointment = self.get_appointment() |
| 114 | + |
103 | 115 | if form.cleaned_data["decision"] == "continue": |
104 | | - return redirect("record_a_mammogram:record_medical_information") |
| 116 | + return redirect( |
| 117 | + "record_a_mammogram:record_medical_information", id=appointment.pk |
| 118 | + ) |
105 | 119 | else: |
106 | | - return redirect("record_a_mammogram:awaiting_images") |
| 120 | + return redirect("record_a_mammogram:awaiting_images", id=appointment.pk) |
107 | 121 |
|
108 | 122 |
|
109 | 123 | class RecordMedicalInformation(FormView): |
110 | 124 | template_name = "record_a_mammogram/record_medical_information.jinja" |
111 | 125 | form_class = RecordMedicalInformationForm |
112 | 126 |
|
| 127 | + def get_appointment(self): |
| 128 | + id = self.kwargs["id"] |
| 129 | + |
| 130 | + return Appointment.objects.get(pk=id) |
| 131 | + |
113 | 132 | def form_valid(self, form): |
114 | 133 | form.save() |
115 | 134 |
|
| 135 | + appointment = self.get_appointment() |
| 136 | + |
116 | 137 | if form.cleaned_data["decision"] == "continue": |
117 | | - return redirect("record_a_mammogram:awaiting_images") |
| 138 | + return redirect("record_a_mammogram:awaiting_images", id=appointment.pk) |
118 | 139 | else: |
119 | | - return redirect("record_a_mammogram:appointment_cannot_go_ahead", id=self.appointment.pk) |
| 140 | + return redirect( |
| 141 | + "record_a_mammogram:appointment_cannot_go_ahead", id=appointment.pk |
| 142 | + ) |
120 | 143 |
|
121 | 144 |
|
122 | 145 | def appointment_cannot_go_ahead(request, id): |
123 | 146 | appointment = Appointment.objects.get(pk=id) |
124 | 147 | participant = appointment.screening_episode.participant |
125 | | - if request.method == 'POST': |
| 148 | + if request.method == "POST": |
126 | 149 | form = AppointmentCannotGoAheadForm(request.POST, instance=appointment) |
127 | 150 | if form.is_valid(): |
128 | 151 | form.save() |
129 | | - return redirect('clinics:index') |
| 152 | + return redirect("clinics:index") |
130 | 153 | else: |
131 | 154 | form = AppointmentCannotGoAheadForm(instance=appointment) |
132 | 155 |
|
133 | 156 | return render( |
134 | 157 | request, |
135 | | - 'record_a_mammogram/appointment_cannot_go_ahead.jinja', |
136 | | - {'form': form, 'participant': participant} |
| 158 | + "record_a_mammogram/appointment_cannot_go_ahead.jinja", |
| 159 | + {"form": form, "participant": participant}, |
137 | 160 | ) |
138 | 161 |
|
139 | 162 |
|
140 | | -def awaiting_images(request): |
| 163 | +def awaiting_images(request, id): |
141 | 164 | return render(request, "record_a_mammogram/awaiting_images.jinja", {}) |
142 | 165 |
|
143 | 166 |
|
|
0 commit comments