Skip to content

Commit d44caf8

Browse files
committed
Redirect to clinic list if appointment cannot proceed
1 parent 20ca9ba commit d44caf8

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

manage_breast_screening/mammograms/views/appointment_workflow_views.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from django.http import Http404, HttpResponse, StreamingHttpResponse
1010
from django.shortcuts import redirect
1111
from django.template.loader import render_to_string
12-
from django.urls import reverse, reverse_lazy
12+
from django.urls import reverse
1313
from django.views import View
1414
from django.views.decorators.http import require_http_methods
1515
from django.views.generic import FormView, TemplateView
@@ -159,7 +159,11 @@ def form_valid(self, form):
159159
class AppointmentCannotGoAhead(InProgressAppointmentMixin, FormView):
160160
template_name = "mammograms/appointment_cannot_go_ahead.jinja"
161161
form_class = AppointmentCannotGoAheadForm
162-
success_url = reverse_lazy("clinics:list_clinics")
162+
163+
def get_success_url(self):
164+
return reverse(
165+
"clinics:show_clinic", kwargs={"pk": self.appointment.clinic_slot.clinic.pk}
166+
)
163167

164168
def get_context_data(self, **kwargs):
165169
context = super().get_context_data(**kwargs)

manage_breast_screening/tests/system/clinical/test_cannot_go_ahead_form.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ def when_i_fill_in_other_details(self):
9797
self.page.locator("#id_other_details").fill("Explain other choice")
9898

9999
def then_i_see_the_clinics_page(self):
100-
expect(self.page).to_have_url(re.compile(reverse("clinics:list_clinics")))
100+
path = reverse(
101+
"clinics:show_clinic",
102+
kwargs={"pk": self.appointment.clinic_slot.clinic.pk},
103+
)
104+
expect(self.page).to_have_url(re.compile(path))
101105

102106
def and_the_appointment_is_updated(self):
103107
self.appointment.refresh_from_db()

0 commit comments

Comments
 (0)