Bugzilla – Attachment 88329 Details for
Bug 17005
Extend /checkouts route to list circulation history
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17005: Add checked_in checkouts to REST API response
Bug-17005-Add-checkedin-checkouts-to-REST-API-resp.patch (text/plain), 4.14 KB, created by
Michal Denar
on 2019-04-18 19:25:37 UTC
(
hide
)
Description:
Bug 17005: Add checked_in checkouts to REST API response
Filename:
MIME Type:
Creator:
Michal Denar
Created:
2019-04-18 19:25:37 UTC
Size:
4.14 KB
patch
obsolete
>From 0104a68ca64b5c4f261a4f4b8baad09cf1f3097f Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Mon, 1 Apr 2019 07:56:39 +0000 >Subject: [PATCH] Bug 17005: Add checked_in checkouts to REST API response > >This patch implements parameter 'checked_in' on checkouts endpoint to >enable getting circulation history. > >Test plan: >1) Apply the patch and restart plack >2) Use your favorite REST API tester and play with /checkouts endpoint: > - use it without checked_in parameter > - use checked_in=1 for getting returned checkouts > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > Koha/REST/V1/Checkouts.pm | 15 +++++++++++++-- > Koha/Schema/Result/OldIssue.pm | 5 +++++ > api/v1/swagger/definitions/checkout.json | 2 +- > api/v1/swagger/paths/checkouts.json | 5 +++++ > 4 files changed, 24 insertions(+), 3 deletions(-) > >diff --git a/Koha/REST/V1/Checkouts.pm b/Koha/REST/V1/Checkouts.pm >index bb349a78ec..b3a0699006 100644 >--- a/Koha/REST/V1/Checkouts.pm >+++ b/Koha/REST/V1/Checkouts.pm >@@ -25,6 +25,7 @@ use C4::Context; > use C4::Circulation; > use Koha::Checkouts; > use Koha::IssuingRules; >+use Koha::Old::Checkouts; > > use Try::Tiny; > >@@ -44,8 +45,14 @@ List Koha::Checkout objects > > sub list { > my $c = shift->openapi->valid_input or return; >+ my $checked_in = $c->validation->param('checked_in'); > try { >- my $checkouts_set = Koha::Checkouts->new; >+ my $checkouts_set; >+ if ( $checked_in ) { >+ $checkouts_set = Koha::Old::Checkouts->new; >+ } else { >+ $checkouts_set = Koha::Checkouts->new; >+ } > my $checkouts = $c->objects->search( $checkouts_set, \&_to_model, \&_to_api ); > return $c->render( status => 200, openapi => $checkouts ); > } catch { >@@ -72,7 +79,10 @@ get one checkout > sub get { > my $c = shift->openapi->valid_input or return; > >- my $checkout = Koha::Checkouts->find( $c->validation->param('checkout_id') ); >+ my $checkout_id = $c->validation->param('checkout_id'); >+ my $checkout = Koha::Checkouts->find( $checkout_id ); >+ $checkout = Koha::Old::Checkouts->find( $checkout_id ) >+ unless ($checkout); > > unless ($checkout) { > return $c->render( >@@ -251,6 +261,7 @@ our $to_model_mapping = { > last_renewed_date => 'lastreneweddate', > checkout_date => 'issuedate', > note_date => 'notedate', >+ checked_in => undef, > }; > > 1; >diff --git a/Koha/Schema/Result/OldIssue.pm b/Koha/Schema/Result/OldIssue.pm >index 2d560896fe..18313c6673 100644 >--- a/Koha/Schema/Result/OldIssue.pm >+++ b/Koha/Schema/Result/OldIssue.pm >@@ -237,6 +237,11 @@ __PACKAGE__->belongs_to( > # Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-04-10 19:55:44 > # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:E2N2paWcCHg916100ry+2A > >+__PACKAGE__->add_columns( >+ '+auto_renew' => { is_boolean => 1 }, >+ '+onsite_checkout' => { is_boolean => 1 } >+); >+ > __PACKAGE__->belongs_to( > "borrower", > "Koha::Schema::Result::Borrower", >diff --git a/api/v1/swagger/definitions/checkout.json b/api/v1/swagger/definitions/checkout.json >index 83cbe1a447..42b9598843 100644 >--- a/api/v1/swagger/definitions/checkout.json >+++ b/api/v1/swagger/definitions/checkout.json >@@ -23,7 +23,7 @@ > }, > "checkin_date": { > "type": ["string", "null"], >- "format": "date", >+ "format": "date-time", > "description": "Date the item was returned" > }, > "last_renewed_date": { >diff --git a/api/v1/swagger/paths/checkouts.json b/api/v1/swagger/paths/checkouts.json >index 70791fd28c..45369e2001 100644 >--- a/api/v1/swagger/paths/checkouts.json >+++ b/api/v1/swagger/paths/checkouts.json >@@ -6,6 +6,11 @@ > "tags": ["patrons", "checkouts"], > "parameters": [{ > "$ref": "../parameters.json#/patron_id_qp" >+ },{ >+ "name": "checked_in", >+ "in": "query", >+ "description": "By default, current checkouts are returned, when this is true then checked in checkouts are returned as result.", >+ "type": "boolean" > }], > "produces": [ > "application/json" >-- >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 17005
:
53843
|
53851
|
53852
|
53858
|
54198
|
56698
|
56699
|
61197
|
87254
|
87255
|
87383
|
87384
|
87385
|
87405
|
87406
|
87407
|
87442
|
87443
|
87444
|
87447
|
87448
|
87449
|
88263
|
88264
|
88265
|
88329
|
88330
|
88331
|
91166
|
91167
|
91168
|
91235
|
91236
|
91237
|
91238
|
93757
|
93758
|
93759
|
93760