Bugzilla – Attachment 120305 Details for
Bug 28254
Make it possible to override rules in PUT /holds/:hold_id/pickup_location
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28254: Add 'override' parameter to Koha::Hold->set_pickup_location
Bug-28254-Add-override-parameter-to-KohaHold-setpi.patch (text/plain), 2.98 KB, created by
Kyle M Hall (khall)
on 2021-04-29 10:48:31 UTC
(
hide
)
Description:
Bug 28254: Add 'override' parameter to Koha::Hold->set_pickup_location
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2021-04-29 10:48:31 UTC
Size:
2.98 KB
patch
obsolete
>From 5fcb6cc56050cd51c51efa2db3db9ea2f9f562fb Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 28 Apr 2021 14:37:12 -0300 >Subject: [PATCH] Bug 28254: Add 'override' parameter to > Koha::Hold->set_pickup_location > >This patch adds a new parameter to the method. If passed+true it makes >the method skip the pickup validation test. > >Tests and POD added for this change. > >To test: >1. Apply this patch >2. Run: > $ kshell > k$ prove t/db_dependent/Koha/Hold.t >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > Koha/Hold.pm | 20 +++++++++++++++++--- > t/db_dependent/Koha/Hold.t | 6 +++++- > 2 files changed, 22 insertions(+), 4 deletions(-) > >diff --git a/Koha/Hold.pm b/Koha/Hold.pm >index 56671f19a8..793b4983bc 100644 >--- a/Koha/Hold.pm >+++ b/Koha/Hold.pm >@@ -47,7 +47,7 @@ Koha::Hold - Koha Hold object class > > =head1 API > >-=head2 Class Methods >+=head2 Class methods > > =cut > >@@ -254,11 +254,19 @@ sub is_pickup_location_valid { > > =head3 set_pickup_location > >- $hold->set_pickup_location({ library_id => $library->id }); >+ $hold->set_pickup_location( >+ { >+ library_id => $library->id, >+ [ override => 0|1 ] >+ } >+ ); > > Updates the hold pickup location. It throws a I<Koha::Exceptions::Hold::InvalidPickupLocation> if > the passed pickup location is not valid. > >+Note: It is up to the caller to verify if I<AllowHoldPolicyOverride> is set when setting the >+B<override> parameter. >+ > =cut > > sub set_pickup_location { >@@ -267,7 +275,13 @@ sub set_pickup_location { > Koha::Exceptions::MissingParameter->throw('The library_id parameter is mandatory') > unless $params->{library_id}; > >- if ( $self->is_pickup_location_valid({ library_id => $params->{library_id} }) ) { >+ if ( >+ $params->{override} >+ || $self->is_pickup_location_valid( >+ { library_id => $params->{library_id} } >+ ) >+ ) >+ { > # all good, set the new pickup location > $self->branchcode( $params->{library_id} )->store; > } >diff --git a/t/db_dependent/Koha/Hold.t b/t/db_dependent/Koha/Hold.t >index a6a5c4a7d6..736b32b305 100755 >--- a/t/db_dependent/Koha/Hold.t >+++ b/t/db_dependent/Koha/Hold.t >@@ -56,7 +56,7 @@ subtest 'patron() tests' => sub { > > subtest 'set_pickup_location() tests' => sub { > >- plan tests => 10; >+ plan tests => 11; > > $schema->storage->txn_begin; > >@@ -125,6 +125,10 @@ subtest 'set_pickup_location() tests' => sub { > $item_hold->discard_changes; > is( $item_hold->branchcode, $library_3->branchcode, 'branchcode remains untouched' ); > >+ $item_hold->set_pickup_location({ library_id => $library_1->branchcode, override => 1 }); >+ $item_hold->discard_changes; >+ is( $item_hold->branchcode, $library_1->branchcode, 'branchcode changed because of \'override\'' ); >+ > $ret = $item_hold->set_pickup_location({ library_id => $library_2->id }); > is( ref($ret), 'Koha::Hold', 'self is returned' ); > >-- >2.24.3 (Apple Git-128)
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 28254
:
120281
|
120282
|
120283
|
120305
|
120306
|
120307
|
120337
|
120338
|
120339
|
120340
|
120457
|
120458