Bugzilla – Attachment 174651 Details for
Bug 24194
Add system preference to disable the use of expiration dates for holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24194: (follow-up) Throw an error if expiration date used
Bug-24194-follow-up-Throw-an-error-if-expiration-d.patch (text/plain), 6.03 KB, created by
Aleisha Amohia
on 2024-11-18 00:34:33 UTC
(
hide
)
Description:
Bug 24194: (follow-up) Throw an error if expiration date used
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2024-11-18 00:34:33 UTC
Size:
6.03 KB
patch
obsolete
>From d19c577ec60f1b982981d83b885a14cc26c578b6 Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Tue, 7 Dec 2021 04:08:18 +0000 >Subject: [PATCH] Bug 24194: (follow-up) Throw an error if expiration date used > >Signed-off-by: Nicolas Giraud <nicolas.giraud@inlibro.com> >--- > C4/ILSDI/Services.pm | 8 ++++++-- > C4/Reserves.pm | 6 +++++- > Koha/Club/Hold.pm | 6 +++++- > Koha/Exceptions/Hold.pm | 4 ++++ > Koha/REST/V1/Clubs/Holds.pm | 9 ++++++++- > Koha/REST/V1/Holds.pm | 9 ++++++++- > 6 files changed, 36 insertions(+), 6 deletions(-) > >diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm >index d7797bb812e..7e2289cc667 100644 >--- a/C4/ILSDI/Services.pm >+++ b/C4/ILSDI/Services.pm >@@ -793,8 +793,12 @@ sub HoldTitle { > > my $resdate = $cgi->param('start_date'); > my $expdate; >- if ( C4::Context->preference('ReserveExpiration') and $cgi->param('expiry_date') ) { >- $expdate = $cgi->param('expiry_date'); >+ if ( C4::Context->preference('ReserveExpiration') ) { >+ if ( $cgi->param('expiry_date') ) { >+ $expdate = $cgi->param('expiry_date'); >+ } >+ } else { >+ return { code => 'expirationDateDisabled' }; > } > > # Add the reserve >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 5008a76b346..23cfea53ab2 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -185,7 +185,7 @@ sub AddReserve { > my $biblionumber = $params->{biblionumber}; > my $priority = $params->{priority}; > my $resdate = $params->{reservation_date}; >- my $patron_expiration_date = C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef; >+ my $patron_expiration_date = $params->{expiration_date}; > my $notes = $params->{notes}; > my $title = $params->{title}; > my $checkitem = $params->{itemnumber}; >@@ -194,6 +194,10 @@ sub AddReserve { > my $non_priority = $params->{non_priority}; > my $item_group_id = $params->{item_group_id}; > >+ if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) { >+ Koha::Exceptions::Hold::ExpirationDateDisabled->throw; >+ } >+ > $resdate ||= dt_from_string; > > # if we have an item selectionned, and the pickup branch is the same as the holdingbranch >diff --git a/Koha/Club/Hold.pm b/Koha/Club/Hold.pm >index 93bc81519d0..4a7776b5d4d 100644 >--- a/Koha/Club/Hold.pm >+++ b/Koha/Club/Hold.pm >@@ -71,6 +71,10 @@ sub add { > Koha::Exceptions::ClubHold::NoPatrons->throw() > unless scalar @enrollments; > >+ if ( !C4::Context->preference('ReserveExpiration') and $params->{expiration_date} ) { >+ Koha::Exceptions::Hold::ExpirationDateDisabled->throw; >+ } >+ > my $biblio = Koha::Biblios->find($params->{biblio_id}); > > my $club_params = { >@@ -126,7 +130,7 @@ sub add { > borrowernumber => $patron_id, > biblionumber => $params->{biblio_id}, > priority => $priority, >- expiration_date => C4::Context->preference('ReserveExpiration') ? $params->{expiration_date} : undef, >+ expiration_date => $params->{expiration_date}, > notes => $params->{notes}, > title => $biblio->title, > itemnumber => $params->{item_id}, >diff --git a/Koha/Exceptions/Hold.pm b/Koha/Exceptions/Hold.pm >index 38577b4126a..8ef583a2569 100644 >--- a/Koha/Exceptions/Hold.pm >+++ b/Koha/Exceptions/Hold.pm >@@ -39,6 +39,10 @@ use Exception::Class ( > 'Koha::Exceptions::Hold::MissingPickupLocation' => { > isa => 'Koha::Exceptions::Hold', > description => 'You must supply a pickup location when placing a hold' >+ }, >+ 'Koha::Exceptions::Hold::ExpirationDateDisabled' => { >+ isa => 'Koha::Exceptions::Hold', >+ description => 'Expiration date not allowed' > } > ); > >diff --git a/Koha/REST/V1/Clubs/Holds.pm b/Koha/REST/V1/Clubs/Holds.pm >index 846cdfd4b18..2c63b6d598b 100644 >--- a/Koha/REST/V1/Clubs/Holds.pm >+++ b/Koha/REST/V1/Clubs/Holds.pm >@@ -53,7 +53,7 @@ sub add { > my $pickup_library_id = $body->{pickup_library_id}; > my $item_id = $body->{item_id}; > my $item_type = $body->{item_type}; >- my $expiration_date = C4::Context->preference('ReserveExpiration') ? $body->{expiration_date} : undef; >+ my $expiration_date = $body->{expiration_date}; > my $notes = $body->{notes}; > my $default_patron_home = $body->{default_patron_home}; > >@@ -95,6 +95,13 @@ sub add { > return $c->render_resource_not_found("Bibliographic record") > unless $biblio; > >+ if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) { >+ return $c->render( >+ status => 400, >+ openapi => { error => "Expiration date not allowed" } >+ ); >+ } >+ > my $club_hold = Koha::Club::Hold::add( > { > club_id => $club_id, >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 7ea21edbcfe..33a72c5cf45 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -82,7 +82,7 @@ sub add { > my $item_id = $body->{item_id}; > my $patron_id = $body->{patron_id}; > my $item_type = $body->{item_type}; >- my $expiration_date = C4::Context->preference('ReserveExpiration') ? $body->{expiration_date} : undef; >+ my $expiration_date = $body->{expiration_date}; > my $notes = $body->{notes}; > my $hold_date = $body->{hold_date}; > my $non_priority = $body->{non_priority}; >@@ -97,6 +97,13 @@ sub add { > ); > } > >+ if ( !C4::Context->preference('ReserveExpiration') and $expiration_date ) { >+ return $c->render( >+ status => 400, >+ openapi => { error => "Expiration date not allowed" } >+ ); >+ } >+ > if ( $item_id and $biblio_id ) { > > $biblio = Koha::Biblios->find($biblio_id); >-- >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 24194
:
96120
|
96121
|
98048
|
98368
|
100927
|
110082
|
110127
|
111443
|
113284
|
113285
|
116626
|
116627
|
117016
|
117085
|
117089
|
117097
|
117098
|
117099
|
117100
|
117101
|
118258
|
118259
|
118260
|
118261
|
118262
|
118263
|
128301
|
128302
|
128303
|
128304
|
128305
|
128306
|
128307
|
128308
|
140646
|
140647
|
144076
|
147527
|
147528
|
150799
|
150800
|
159060
|
159061
|
167796
|
167797
|
169174
|
174650
| 174651 |
174652