Bugzilla – Attachment 173209 Details for
Bug 30661
Able to update more hold parameters via REST API
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30661: Allow to update more hold parameters via REST API
Bug-30661-Allow-to-update-more-hold-parameters-via.patch (text/plain), 5.81 KB, created by
Pedro Amorim
on 2024-10-23 12:04:39 UTC
(
hide
)
Description:
Bug 30661: Allow to update more hold parameters via REST API
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2024-10-23 12:04:39 UTC
Size:
5.81 KB
patch
obsolete
>From 95dd1e72f8d674fc439391c97d01f67a3f239872 Mon Sep 17 00:00:00 2001 >From: Johanna Raisa <johanna.raisa@gmail.com> >Date: Tue, 3 May 2022 10:39:56 +0300 >Subject: [PATCH] Bug 30661: Allow to update more hold parameters via REST API > >This patch adds hold_date and expiration_date to holds edit endpoint > >Test plan: > >1) prove t/db_dependent/api/v1/holds.t > >Sponsored-by: Koha-Suomi Oy >Signed-off-by: David Nind <david@davidnind.com> >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >--- > Koha/REST/V1/Holds.pm | 16 +++++++---- > api/v1/swagger/paths/holds.yaml | 8 ++++++ > t/db_dependent/api/v1/holds.t | 50 +++++++++++++++++++++++++-------- > 3 files changed, 58 insertions(+), 16 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index ac9979e0ba..c4398bb59d 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -276,17 +276,23 @@ sub edit { > > $pickup_library_id //= $hold->branchcode; > my $priority = $body->{priority} // $hold->priority; >+ my $hold_date = $body->{hold_date} // $hold->reservedate; >+ my $expiration_date = $body->{expiration_date} // $hold->expirationdate; >+ > # suspended_until can also be set to undef > my $suspended_until = $body->{suspended_until} || $hold->suspend_until; > > my $params = { >- reserve_id => $hold->id, >- branchcode => $pickup_library_id, >- rank => $priority, >- suspend_until => $suspended_until, >- itemnumber => $hold->itemnumber, >+ reserve_id => $hold->id, >+ branchcode => $pickup_library_id, >+ rank => $priority, >+ suspend_until => $suspended_until, >+ itemnumber => $hold->itemnumber, >+ reservedate => $hold_date, >+ expirationdate => $expiration_date, > }; > >+ > C4::Reserves::ModReserve($params); > $hold->discard_changes; # refresh > >diff --git a/api/v1/swagger/paths/holds.yaml b/api/v1/swagger/paths/holds.yaml >index abf00fd726..6b5c792095 100644 >--- a/api/v1/swagger/paths/holds.yaml >+++ b/api/v1/swagger/paths/holds.yaml >@@ -287,6 +287,14 @@ > description: Date until which the hold has been suspended > type: string > format: date-time >+ hold_date: >+ description: Hold date >+ type: string >+ format: date >+ expiration_date: >+ description: Hold's expiration date >+ type: string >+ format: date > additionalProperties: false > consumes: > - application/json >diff --git a/t/db_dependent/api/v1/holds.t b/t/db_dependent/api/v1/holds.t >index 8632c25940..63be8e9d18 100755 >--- a/t/db_dependent/api/v1/holds.t >+++ b/t/db_dependent/api/v1/holds.t >@@ -917,7 +917,7 @@ subtest 'pickup_locations() tests' => sub { > > subtest 'edit() tests' => sub { > >- plan tests => 39; >+ plan tests => 47; > > $schema->storage->txn_begin; > >@@ -968,10 +968,12 @@ subtest 'edit() tests' => sub { > { > class => "Koha::Holds", > value => { >- biblionumber => $biblio->biblionumber, >- branchcode => $library_3->branchcode, >- itemnumber => undef, >- priority => 1, >+ biblionumber => $biblio->biblionumber, >+ branchcode => $library_3->branchcode, >+ itemnumber => undef, >+ priority => 1, >+ reservedate => '2022-01-01', >+ expirationdate => '2022-03-01' > } > } > ); >@@ -1026,17 +1028,32 @@ subtest 'edit() tests' => sub { > $biblio_hold->discard_changes; > is( $biblio_hold->branchcode, $library_2->id, 'Pickup location changed correctly' ); > >+ $biblio_hold_data = { >+ hold_date => '2022-01-02', >+ expiration_date => '2022-03-02' >+ }; >+ >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $biblio_hold->id => json => $biblio_hold_data ) >+ ->status_is(200); >+ >+ $biblio_hold->discard_changes; >+ is( $biblio_hold->reservedate, '2022-01-02', 'Hold date changed correctly' ); >+ is( $biblio_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' ); >+ >+ > # Test item-level holds > my $item_hold = $builder->build_object( > { > class => "Koha::Holds", > value => { >- biblionumber => $biblio->biblionumber, >- branchcode => $library_3->branchcode, >- itemnumber => $item->itemnumber, >- priority => 1, >- suspend => 0, >- suspend_until => undef, >+ biblionumber => $biblio->biblionumber, >+ branchcode => $library_3->branchcode, >+ itemnumber => $item->itemnumber, >+ priority => 1, >+ suspend => 0, >+ suspend_until => undef, >+ reservedate => '2022-01-01', >+ expirationdate => '2022-03-01' > } > } > ); >@@ -1091,6 +1108,17 @@ subtest 'edit() tests' => sub { > is( $item_hold->suspend, 0, 'Location change should not activate suspended status' ); > is( $item_hold->suspend_until, undef, 'Location change should keep suspended_until be undef' ); > >+ $item_hold_data = { >+ hold_date => '2022-01-02', >+ expiration_date => '2022-03-02' >+ }; >+ >+ $t->patch_ok( "//$userid:$password@/api/v1/holds/" . $item_hold->id => json => $item_hold_data )->status_is(200); >+ >+ $item_hold->discard_changes; >+ is( $item_hold->reservedate, '2022-01-02', 'Hold date changed correctly' ); >+ is( $item_hold->expirationdate, '2022-03-02', 'Expiration date changed correctly' ); >+ > $schema->storage->txn_rollback; > > }; >-- >2.39.5
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 30661
:
139973
|
139974
|
140221
|
140359
|
173116
|
173117
|
173122
|
173123
| 173209