Bugzilla – Attachment 44207 Details for
Bug 14310
Add ability to suspend and resume individual holds from the patron holds table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14310 [QA Followup] - Deal with error conditions
Bug-14310-QA-Followup---Deal-with-error-conditions.patch (text/plain), 4.89 KB, created by
Kyle M Hall (khall)
on 2015-10-30 14:35:23 UTC
(
hide
)
Description:
Bug 14310 [QA Followup] - Deal with error conditions
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2015-10-30 14:35:23 UTC
Size:
4.89 KB
patch
obsolete
>From 3482cfed4e86f22a80712dc76ba288fae472a46d Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >Date: Fri, 30 Oct 2015 10:27:10 -0400 >Subject: [PATCH] Bug 14310 [QA Followup] - Deal with error conditions > >--- > .../intranet-tmpl/prog/en/includes/strings.inc | 3 ++ > koha-tmpl/intranet-tmpl/prog/en/js/holds.js | 21 ++++++++++++++++- > svc/hold/resume | 8 ++++++- > svc/hold/suspend | 23 ++++++++++++++----- > 4 files changed, 46 insertions(+), 9 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >index 3995b6d..62af2a3 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/strings.inc >@@ -35,5 +35,8 @@ > var SUSPEND = _("Suspend"); > var SUSPEND_HOLD_ON = _("Suspend hold on"); > var CLEAR_DATE_TO_SUSPEND_INDEFINITELY = _("Clear date to suspend indefinitely"); >+ var SUSPEND_HOLD_ERROR_DATE = _("Unable to suspend hold, invalid date"); >+ var SUSPEND_HOLD_ERROR_NOT_FOUND = _("Unable to suspend hold, hold not found"); >+ var RESUME_HOLD_ERROR_NOT_FOUND = _("Unable to resume, hold not found"); > //]]> > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js >index a6c8ca6..f9c3d86 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/holds.js >@@ -162,7 +162,14 @@ $(document).ready(function() { > var id = $(this).attr("id").replace("resume", ""); > var hold = holds[id]; > $.post('/cgi-bin/koha/svc/hold/resume', { "reserve_id": hold.reserve_id }, function( data ){ >- holdsTable.api().ajax.reload(); >+ if ( data.success ) { >+ holdsTable.api().ajax.reload(); >+ } else { >+ if ( data.error == "HOLD_NOT_FOUND" ) { >+ alert ( RESUME_HOLD_ERROR_NOT_FOUND ); >+ holdsTable.api().ajax.reload(); >+ } >+ } > }); > }); > }); >@@ -209,7 +216,17 @@ $(document).ready(function() { > e.preventDefault(); > $.post('/cgi-bin/koha/svc/hold/suspend', $('#suspend-modal-form').serialize(), function( data ){ > $('#suspend-modal').modal('hide'); >- holdsTable.api().ajax.reload(); >+ if ( data.success ) { >+ holdsTable.api().ajax.reload(); >+ } else { >+ if ( data.error == "INVALID_DATE" ) { >+ alert( SUSPEND_HOLD_ERROR_DATE ); >+ } >+ else if ( data.error == "HOLD_NOT_FOUND" ) { >+ alert ( SUSPEND_HOLD_ERROR_NOT_FOUND ); >+ holdsTable.api().ajax.reload(); >+ } >+ } > }); > }); > >diff --git a/svc/hold/resume b/svc/hold/resume >index 03cd017..52f3508 100755 >--- a/svc/hold/resume >+++ b/svc/hold/resume >@@ -38,11 +38,17 @@ if ( $auth_status ne "ok" ) { > } > > binmode STDOUT, ":encoding(UTF-8)"; >-print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+print $input->header( -type => 'text/json', -charset => 'UTF-8' ); > > my $reserve_id = $input->param('reserve_id'); > > my $hold = Koha::Holds->find( $reserve_id ); >+ >+unless ( $hold ) { >+ print to_json( { success => 0, error => "HOLD_NOT_FOUND" } ); >+ exit; >+} >+ > $hold->resume(); > > print to_json( { success => !$hold->suspend() } ); >diff --git a/svc/hold/suspend b/svc/hold/suspend >index 880e41a..bd5382b 100755 >--- a/svc/hold/suspend >+++ b/svc/hold/suspend >@@ -30,22 +30,33 @@ use Koha::Holds; > my $input = new CGI; > > my ( $auth_status, $sessionID ) = >- check_cookie_auth( $input->cookie('CGISESSID'), >- { circulate => 'circulate_remaining_permissions' } ); >+ check_cookie_auth( $input->cookie('CGISESSID'), { circulate => 'circulate_remaining_permissions' } ); > > if ( $auth_status ne "ok" ) { > exit 0; > } > > binmode STDOUT, ":encoding(UTF-8)"; >-print $input->header( -type => 'text/plain', -charset => 'UTF-8' ); >+print $input->header( -type => 'text/json', -charset => 'UTF-8' ); > > my $reserve_id = $input->param('reserve_id'); > > my $suspend_until = $input->param('suspend_until') || undef; >-$suspend_until = dt_from_string( $suspend_until ) if $suspend_until; >+if ($suspend_until) { >+ eval { $suspend_until = dt_from_string($suspend_until) }; > >-my $hold = Koha::Holds->find( $reserve_id ); >-$hold->suspend_hold( $suspend_until ); >+ if ($@) { >+ print to_json( { success => 0, error => 'INVALID_DATE' } ); >+ exit; >+ } >+} >+ >+my $hold = Koha::Holds->find($reserve_id); >+unless ($hold) { >+ print to_json( { success => 0, error => 'HOLD_NOT_FOUND' } ); >+ exit; >+} >+ >+$hold->suspend_hold($suspend_until); > > print to_json( { success => $hold->suspend() } ); >-- >1.7.2.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 14310
:
39750
|
39751
|
39752
|
39753
|
39754
|
40024
|
40030
|
40031
|
40034
|
43525
|
43526
|
43830
|
43831
|
43832
|
43978
|
44203
|
44204
|
44205
|
44206
|
44207
|
46857
|
46858
|
46859
|
46860
|
46861
|
46862
|
46870
|
46871
|
46872
|
46873
|
46874
|
46875
|
46876