From 2a0ef624c6557ac8b7e69a4191bd344b43e9bda8 Mon Sep 17 00:00:00 2001 From: Cameron Hargreaves Date: Wed, 7 Jan 2026 10:41:00 +0000 Subject: [PATCH] Add resume appointment link The link will only show for appointments the current user has started Currently the link will send the user to the start of the appointment To be altered to send the user to the first incomplete page of the workflow in a further PR. --- .../clinics/jinja2/clinics/show.jinja | 12 ++++++++++++ .../jinja2/components/resume-appointment/macro.jinja | 3 +++ .../components/resume-appointment/template.jinja | 12 ++++++++++++ .../mammograms/presenters/appointment_presenters.py | 7 +++++++ 4 files changed, 34 insertions(+) create mode 100644 manage_breast_screening/core/jinja2/components/resume-appointment/macro.jinja create mode 100644 manage_breast_screening/core/jinja2/components/resume-appointment/template.jinja diff --git a/manage_breast_screening/clinics/jinja2/clinics/show.jinja b/manage_breast_screening/clinics/jinja2/clinics/show.jinja index ac13afdd1..cb38cc64b 100644 --- a/manage_breast_screening/clinics/jinja2/clinics/show.jinja +++ b/manage_breast_screening/clinics/jinja2/clinics/show.jinja @@ -8,6 +8,7 @@ {% from 'components/appointment-status/macro.jinja' import app_appointment_status %} {% from 'components/check-in/macro.jinja' import app_check_in %} {% from 'components/start-appointment/macro.jinja' import app_start_appointment %} +{% from 'components/resume-appointment/macro.jinja' import resume_appointment %} {% block beforeContent %} {{ backLink({ @@ -101,6 +102,17 @@ ), csrf_input=csrf_input ) }} + {{ resume_appointment( + request.user, + presented_appointment, + resume_appointment_url=url( + 'mammograms:start_appointment', + kwargs={ + 'pk': presented_appointment.pk, + } + ), + csrf_input=csrf_input + ) }} {% endset %} {% do table_rows.append([ diff --git a/manage_breast_screening/core/jinja2/components/resume-appointment/macro.jinja b/manage_breast_screening/core/jinja2/components/resume-appointment/macro.jinja new file mode 100644 index 000000000..bab9016e4 --- /dev/null +++ b/manage_breast_screening/core/jinja2/components/resume-appointment/macro.jinja @@ -0,0 +1,3 @@ +{% macro resume_appointment(user, presented_appointment, resume_appointment_url, csrf_input) %} + {%- include 'components/resume-appointment/template.jinja' -%} +{% endmacro %} diff --git a/manage_breast_screening/core/jinja2/components/resume-appointment/template.jinja b/manage_breast_screening/core/jinja2/components/resume-appointment/template.jinja new file mode 100644 index 000000000..6d13f98f9 --- /dev/null +++ b/manage_breast_screening/core/jinja2/components/resume-appointment/template.jinja @@ -0,0 +1,12 @@ +{% if resume_appointment_url is undefined %} + {{ raise('resume_appointment_url is required') }} +{% endif %} + +
+
+

+ +

+ {{ csrf_input }} +
+
diff --git a/manage_breast_screening/mammograms/presenters/appointment_presenters.py b/manage_breast_screening/mammograms/presenters/appointment_presenters.py index 38dcba402..47ee894fa 100644 --- a/manage_breast_screening/mammograms/presenters/appointment_presenters.py +++ b/manage_breast_screening/mammograms/presenters/appointment_presenters.py @@ -79,6 +79,12 @@ def can_be_started_by(self, user): Permission.START_MAMMOGRAM_APPOINTMENT, self._appointment ) and AppointmentStatusUpdater.is_startable(self._appointment) + def can_be_resumed_by(self, user): + return ( + self._appointment.current_status.is_in_progress() + and user.pk == self._appointment.current_status.created_by.pk + ) + @cached_property def special_appointment_tag_properties(self): return { @@ -104,6 +110,7 @@ def current_status(self): "key": current_status.name, "is_confirmed": current_status.name == AppointmentStatus.CONFIRMED, "is_screened": current_status.name == AppointmentStatus.SCREENED, + "is_in_progress": current_status.is_in_progress(), } @cached_property