Bugzilla – Attachment 93735 Details for
Bug 23710
Holds broken on intranet, displays a JSON page with an error
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23710: (follow-up) Human readable error messages in request.tt, check AllowHoldPolicyOverride and AllowHoldDateInFuture in Koha::REST::V1::Holds.pm
Bug-23710-follow-up-Human-readable-error-messages-.patch (text/plain), 4.27 KB, created by
Marcel de Rooy
on 2019-10-04 10:06:15 UTC
(
hide
)
Description:
Bug 23710: (follow-up) Human readable error messages in request.tt, check AllowHoldPolicyOverride and AllowHoldDateInFuture in Koha::REST::V1::Holds.pm
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2019-10-04 10:06:15 UTC
Size:
4.27 KB
patch
obsolete
>From 9c6ce692fa4f9518ca856bc1f1ad775d8d2c6665 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Wed, 2 Oct 2019 11:26:57 -0300 >Subject: [PATCH] Bug 23710: (follow-up) Human readable error messages in > request.tt, check AllowHoldPolicyOverride and AllowHoldDateInFuture in > Koha::REST::V1::Holds.pm >Content-Type: text/plain; charset=utf-8 > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/REST/V1/Holds.pm | 7 +++++-- > .../intranet-tmpl/prog/en/modules/reserve/request.tt | 20 ++++++++++++++++++-- > 2 files changed, 23 insertions(+), 4 deletions(-) > >diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm >index 5ccc1fde35..04d1014b6a 100644 >--- a/Koha/REST/V1/Holds.pm >+++ b/Koha/REST/V1/Holds.pm >@@ -84,6 +84,7 @@ sub add { > my $item_type = $body->{item_type}; > my $expiration_date = $body->{expiration_date}; > my $notes = $body->{notes}; >+ my $hold_date = C4::Context->preference( 'AllowHoldDateInFuture' )?$body->{hold_date}:undef; > > if ( $item_id and $biblio_id ) { > >@@ -135,7 +136,9 @@ sub add { > ? C4::Reserves::CanItemBeReserved( $patron_id, $item_id ) > : C4::Reserves::CanBookBeReserved( $patron_id, $biblio_id ); > >- unless ( $can_place_hold->{status} eq 'OK' ) { >+ my $can_override = C4::Context->preference('AllowHoldPolicyOverride'); >+ >+ unless ($can_override || $can_place_hold->{status} eq 'OK' ) { > return $c->render( > status => 403, > openapi => >@@ -156,7 +159,7 @@ sub add { > $biblio_id, > undef, # $bibitems param is unused > $priority, >- undef, # hold date, we don't allow it currently >+ $hold_date, > $expiration_date, > $notes, > $biblio->title, >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 10c8cd7a08..9170dd3922 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -948,6 +948,17 @@ > [% END %][% END %][% END %] > }; > var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items."); >+ var ERROR_MAP = { >+ damaged: _("Item damaged"), >+ ageRestricted: _("Age restricted"), >+ tooManyHoldsForThisRecord: _("Exceeded max holds per record"), >+ tooManyReservesToday: _("Daily hold limit reached for patron"), >+ tooManyReserves: _("Too many holds"), >+ notReservable: _("Not holdable"), >+ cannotReserveFromOtherBranches: _("Patron is from different library"), >+ itemAlreadyOnHold: _("Patron already has hold for this item"), >+ cannotBeTransferred: _("Cannot be transferred to pickup library") >+ } > columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %] > > $(document).ready(function() { >@@ -1005,7 +1016,7 @@ > > $("#club-request-form, #hold-request-form").on("submit", function() { > let $t = $(this); >- $('.clubalert').addClass('hide'); >+ $('.clubalert, .holdalert').addClass('hide'); > let biblionumbers = [biblionumber]; > let biblionumbers_text; > const data = { >@@ -1048,7 +1059,12 @@ > document.location = url; > }) > .fail(function(err) { >- $('.clubalert, .holdalert').removeClass('hide').html(err.responseJSON.error); >+ var message = err.responseJSON.error; >+ var match = err.responseJSON.error.match(/Reason: (\w+)\s*$/); >+ if(match && ERROR_MAP[match[1]]) { >+ message = '<div><strong>'+_("Cannot place hold")+'</strong></div><div>'+ERROR_MAP[match[1]]+'</div>' >+ } >+ $('.clubalert, .holdalert').removeClass('hide').html(message); > }); > } > }); >-- >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 23710
:
93360
|
93362
|
93386
|
93387
|
93491
|
93661
|
93734
| 93735 |
93737