Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions manage_breast_screening/clinics/jinja2/clinics/show.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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([
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{% macro resume_appointment(user, presented_appointment, resume_appointment_url, csrf_input) %}
{%- include 'components/resume-appointment/template.jinja' -%}
{% endmacro %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% if resume_appointment_url is undefined %}
{{ raise('resume_appointment_url is required') }}
{% endif %}

<div data-module="app-resume-appointment" data-appointment-id="{{ presented_appointment.pk }}" {% if not presented_appointment.can_be_resumed_by(user) %}hidden{% endif %}>
<form action="{{ resume_appointment_url }}" method="post" novalidate>
<p>
<button class="app-button app-button--link">Resume Appointment<span class="nhsuk-u-visually-hidden"> {{ presented_appointment.participant.full_name }}</span></button>
</p>
{{ csrf_input }}
</form>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down
Loading