Bugzilla – Attachment 117658 Details for
Bug 18729
Librarian unable to update hold pickup library from patron pages without "modify_holds_priority" permission
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18729: (follow-up) Adjust API to new spec
Bug-18729-follow-up-Adjust-API-to-new-spec.patch (text/plain), 3.64 KB, created by
David Nind
on 2021-03-04 09:46:45 UTC
(
hide
)
Description:
Bug 18729: (follow-up) Adjust API to new spec
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-03-04 09:46:45 UTC
Size:
3.64 KB
patch
obsolete
>From 7ccb46a576bb92fb2b32f321f9f1a37f8de22797 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 14 Dec 2020 12:13:38 -0300 >Subject: [PATCH] Bug 18729: (follow-up) Adjust API to new spec > >The previous patch introduces some behavioural changes to the API, as >well as the data types that need to be passed; all happens in the tests. > >This patch adapts the route so it complies with those changes: >- JSON object containing pickup_library_id attribute is now passed back > and forth. >- The controller should take care of checking the pickup location is > valid, using the available tools. > >To test: >1. Apply the patches, up to the tests >2. Run: > $ kshell > k$ prove t/db_dependent/api/v1/holds.t >=> ERROR: Tests fail because the controller doesn't implement the >desired behavior >3. Apply this patch >4. Repeat 2 >=> SUCCESS: Tests pass! >5. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/REST/V1/Holds.pm | 23 ++++++++++++++++++++--- > api/v1/swagger/paths/holds.json | 22 ++++++++++++++++++++-- > 2 files changed, 40 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 590877d53c..cba890e162 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -493,6 +493,9 @@ sub update_pickup_location { > my $c = shift->openapi->valid_input or return; > > my $hold_id = $c->validation->param('hold_id'); >+ my $body = $c->validation->param('body'); >+ my $pickup_library_id = $body->{pickup_library_id}; >+ > my $hold = Koha::Holds->find($hold_id); > > unless ($hold) { >@@ -503,13 +506,27 @@ sub update_pickup_location { > } > > return try { >- my $pickup_location = $c->req->json; > >- $hold->branchcode($pickup_location)->store; >+ $hold->set_pickup_location({ library_id => $pickup_library_id }); > >- return $c->render( status => 200, openapi => $pickup_location ); >+ return $c->render( >+ status => 200, >+ openapi => { >+ pickup_library_id => $pickup_library_id >+ } >+ ); > } > catch { >+ >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Hold::InvalidPickupLocation') ) { >+ return $c->render( >+ status => 400, >+ openapi => { >+ error => "$_" >+ } >+ ); >+ } >+ > $c->unhandled_exception($_); > }; > } >diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json >index ebaed331f2..dd26dd2746 100644 >--- a/api/v1/swagger/paths/holds.json >+++ b/api/v1/swagger/paths/holds.json >@@ -718,7 +718,13 @@ > "description": "Pickup location", > "required": true, > "schema": { >- "type": "string" >+ "type": "object", >+ "properties": { >+ "pickup_library_id": { >+ "type": "string", >+ "description": "Internal identifier for the pickup library" >+ } >+ } > } > } > ], >@@ -729,7 +735,19 @@ > "200": { > "description": "The new pickup location value for the hold", > "schema": { >- "type": "string" >+ "type": "object", >+ "properties": { >+ "pickup_library_id": { >+ "type": "string", >+ "description": "Internal identifier for the pickup library" >+ } >+ } >+ } >+ }, >+ "400": { >+ "description": "Missing or wrong parameters", >+ "schema": { >+ "$ref": "../definitions.json#/error" > } > }, > "401": { >-- >2.11.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 18729
:
114067
|
114311
|
114337
|
114388
|
114389
|
114390
|
114391
|
114393
|
114394
|
114395
|
114396
|
117656
|
117657
|
117658
|
117659
|
119711
|
119712
|
119713
|
119714