Bugzilla – Attachment 158326 Details for
Bug 35247
Add new route to simply list old reserves by patron id
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35247: Add new API route to list old reserves by patron
Bug-35247-Add-new-API-route-to-list-old-reserves-b.patch (text/plain), 5.32 KB, created by
Owen Leonard
on 2023-11-03 11:41:26 UTC
(
hide
)
Description:
Bug 35247: Add new API route to list old reserves by patron
Filename:
MIME Type:
Creator:
Owen Leonard
Created:
2023-11-03 11:41:26 UTC
Size:
5.32 KB
patch
obsolete
>From 481f2b75d6fb89a09b66ed01e75a1fc23ddbb9ad Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Fri, 3 Nov 2023 12:05:42 +0100 >Subject: [PATCH] Bug 35247: Add new API route to list old reserves by patron > >Test plan: > >1) Apply this patch >2) Go to "/api/v1/patrons/{patron_id}/old_holds" to see old reserves by > patron > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >--- > Koha/REST/V1/Patrons/OldHolds.pm | 66 +++++++++++++++++++++ > api/v1/swagger/paths/patrons_old_holds.yaml | 62 +++++++++++++++++++ > api/v1/swagger/swagger.yaml | 2 + > 3 files changed, 130 insertions(+) > create mode 100644 Koha/REST/V1/Patrons/OldHolds.pm > create mode 100644 api/v1/swagger/paths/patrons_old_holds.yaml > >diff --git a/Koha/REST/V1/Patrons/OldHolds.pm b/Koha/REST/V1/Patrons/OldHolds.pm >new file mode 100644 >index 0000000000..f26520f68b >--- /dev/null >+++ b/Koha/REST/V1/Patrons/OldHolds.pm >@@ -0,0 +1,66 @@ >+package Koha::REST::V1::Patrons::OldHolds; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use Mojo::Base 'Mojolicious::Controller'; >+ >+use Koha::Patrons; >+ >+=head1 NAME >+ >+Koha::REST::V1::Patrons::OldHolds >+ >+=head1 API >+ >+=head2 Methods >+ >+=head3 list >+ >+Controller function that handles listing Koha::OldHold objects for the requested patron >+ >+=cut >+ >+sub list { >+ my $c = shift->openapi->valid_input or return; >+ >+ my $patron = Koha::Patrons->find( $c->param('patron_id') ); >+ >+ unless ( $patron ) { >+ return $c->render( >+ status => 404, >+ openapi => { >+ error => 'Patron not found' >+ } >+ ); >+ } >+ >+ return try { >+ >+ my $old_holds = $c->objects->search( $patron->old_holds ); >+ >+ return $c->render( >+ status => 200, >+ openapi => $old_holds >+ ); >+ } >+ catch { >+ $c->unhandled_exception($_); >+ }; >+} >+ >+1; >diff --git a/api/v1/swagger/paths/patrons_old_holds.yaml b/api/v1/swagger/paths/patrons_old_holds.yaml >new file mode 100644 >index 0000000000..7bae57ecea >--- /dev/null >+++ b/api/v1/swagger/paths/patrons_old_holds.yaml >@@ -0,0 +1,62 @@ >+--- >+"/patrons/{patron_id}/old_holds": >+ get: >+ x-mojo-to: Patrons::OldHolds#list >+ operationId: getPatronOldHolds >+ tags: >+ - old_holds >+ summary: List old holds for a patron >+ parameters: >+ - $ref: "../swagger.yaml#/parameters/patron_id_pp" >+ - $ref: "../swagger.yaml#/parameters/match" >+ - $ref: "../swagger.yaml#/parameters/order_by" >+ - $ref: "../swagger.yaml#/parameters/page" >+ - $ref: "../swagger.yaml#/parameters/per_page" >+ - $ref: "../swagger.yaml#/parameters/q_param" >+ - $ref: "../swagger.yaml#/parameters/q_body" >+ - $ref: "../swagger.yaml#/parameters/request_id_header" >+ - name: x-koha-embed >+ in: header >+ required: false >+ description: Embed list sent as a request header >+ type: array >+ items: >+ type: string >+ enum: >+ - cancellation_requested >+ collectionFormat: csv >+ produces: >+ - application/json >+ responses: >+ "200": >+ description: The patron old holds >+ schema: >+ type: array >+ items: >+ $ref: "../swagger.yaml#/definitions/hold" >+ "401": >+ description: Authentication required >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "403": >+ description: Access forbidden >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "404": >+ description: Patron not found >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "500": >+ description: | >+ Internal server error. Possible `error_code` attribute values: >+ >+ * `internal_server_error` >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ "503": >+ description: Under maintenance >+ schema: >+ $ref: "../swagger.yaml#/definitions/error" >+ x-koha-authorization: >+ permissions: >+ borrowers: edit_borrowers >diff --git a/api/v1/swagger/swagger.yaml b/api/v1/swagger/swagger.yaml >index 3d056e2700..d4edfd895a 100644 >--- a/api/v1/swagger/swagger.yaml >+++ b/api/v1/swagger/swagger.yaml >@@ -409,6 +409,8 @@ paths: > $ref: "./paths/patrons_extended_attributes.yaml#/~1patrons~1{patron_id}~1extended_attributes~1{extended_attribute_id}" > "/patrons/{patron_id}/holds": > $ref: "./paths/patrons_holds.yaml#/~1patrons~1{patron_id}~1holds" >+ "/patrons/{patron_id}/old_holds": >+ $ref: "./paths/patrons_old_holds.yaml#/~1patrons~1{patron_id}~1old_holds" > "/patrons/{patron_id}/password": > $ref: "./paths/patrons_password.yaml#/~1patrons~1{patron_id}~1password" > "/patrons/{patron_id}/password/expiration_date": >-- >2.30.2
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 35247
:
158325
| 158326 |
158327