Bugzilla – Attachment 108017 Details for
Bug 26181
Holds placed via the REST API should not be forced by default even if AllowHoldPolicyOverride is enabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26181: Disable override by default in /holds
Bug-26181-Disable-override-by-default-in-holds.patch (text/plain), 2.16 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-08-10 20:35:12 UTC
(
hide
)
Description:
Bug 26181: Disable override by default in /holds
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-08-10 20:35:12 UTC
Size:
2.16 KB
patch
obsolete
>From 5d56712660ac8f799069efe0d13d5b2fbbc46cba Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 10 Aug 2020 17:30:25 -0300 >Subject: [PATCH] Bug 26181: Disable override by default in /holds > >This patch disables AllowHoldPolicyOverride by default in /holds. It >also adds a header that can be used to request the override explicitly. > >Tests are added for this behaviour > >To test: >1. Apply the regression tests patch >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/holds.t >=> FAIL: Tests fail because the behaviour is not implemented >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/REST/V1/Holds.pm | 9 ++++++++- > api/v1/swagger/paths/holds.json | 3 +++ > 2 files changed, 11 insertions(+), 1 deletion(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 87d7c05336..947a563879 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -19,6 +19,8 @@ use Modern::Perl; > > use Mojo::Base 'Mojolicious::Controller'; > >+use Mojo::JSON qw(decode_json); >+ > use C4::Biblio; > use C4::Reserves; > >@@ -132,7 +134,12 @@ sub add { > ? C4::Reserves::CanItemBeReserved( $patron_id, $item_id ) > : C4::Reserves::CanBookBeReserved( $patron_id, $biblio_id ); > >- my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); >+ my $override_header = $c->req->headers->header('x-koha-override'); >+ $override_header = decode_json($override_header) >+ if $override_header; >+ >+ my $can_override = $override_header->{AllowHoldPolicyOverride} >+ and C4::Context->preference('AllowHoldPolicyOverride'); > > unless ($can_override || $can_place_hold->{status} eq 'OK' ) { > return $c->render( >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index 847d3b83ca..3ac76d67c4 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -257,6 +257,9 @@ > "permissions": { > "reserveforothers": "1" > } >+ }, >+ "x-koha-override": { >+ "AllowHoldPolicyOverride": 1 > } > } > }, >-- >2.28.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26181
:
108016
|
108017
|
116720
|
116721
|
116757
|
116758
|
116786
|
116787