From 8a3bf8c10891630bba88025f11401cd9617873bf Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 24 Jul 2023 16:08:50 -0300 Subject: [PATCH] Bug 34365: Add cancellation request flow to DELETE /holds This patch adds a new `x-koha-override` header to allow enforcing the cancellation request flow for waiting holds. If the hold is not waiting, the header has no effect. To test: 1. Apply the tests patch 2. Run: $ ktd --shell k$ prove t/db_dependent/api/v1/holds.t => FAIL: The endpoint doesn't implement the required logic 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! The endpoint behavior is changed! 5. Sign off :-D Signed-off-by: Emily Lamancusa --- Koha/REST/V1/Holds.pm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index 00f761511d..79deaaac25 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -317,6 +317,19 @@ sub delete { } return try { + + my $overrides = $c->stash('koha.overrides'); + + if ( $overrides->{'cancellation-request-flow'} && $hold->is_waiting ) { + + $hold->add_cancellation_request; + + return $c->render( + status => 202, + openapi => q{}, + ); + } + $hold->cancel; return $c->render( -- 2.34.1