Bugzilla – Attachment 68931 Details for
Bug 7317
Add an Interlibrary Loan Module to Circulation and OPAC
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7317: Handle backend absense more gracefuly
Bug-7317-Handle-backend-absense-more-gracefuly.patch (text/plain), 34.31 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-11-03 19:12:10 UTC
(
hide
)
Description:
Bug 7317: Handle backend absense more gracefuly
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-11-03 19:12:10 UTC
Size:
34.31 KB
patch
obsolete
>From 89c5077b4156d5a60999f42321e7005340c3ff26 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Tue, 31 Oct 2017 16:28:53 -0300 >Subject: [PATCH] Bug 7317: Handle backend absense more gracefuly > >5/ This patch makes Koha::Illrequest->load_backend raise an exception >if the passed backend is invalid. This way we will catch more errors introduced. > >The patch also disables the 'New Ill request' when no backends are available. Gets >rid of a related warnings. > >Both OPAC and Intranet now display a warning message when no backends >are available. > >Tests are added for the load_backend changes. > >4/ This patch fixes the path for the checkboxes jquery plugin, and removes the include >for tablesorter, as this implementation uses Datatables. This is obviously code for older >Koha, ported to master. > >TODO: There's something wrong on the styling. My idea is to get rid >of the custom column visualization tool, and have it display as regular >DataTables. We can then introduce the use of colvis on a separate bug >report. > >Note: POD coverage for the exceptions file is wrongly tested. It is a false positive. > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Exceptions/Ill.pm | 47 +++ > Koha/Illrequest.pm | 18 +- > Koha/Illrequest/Config.pm | 18 ++ > Koha/Illrequestattribute.pm | 4 +- > about.pl | 14 + > ill/ill-requests.pl | 329 +++++++++++---------- > .../intranet-tmpl/prog/en/includes/ill-toolbar.inc | 10 +- > koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 9 +- > .../prog/en/modules/ill/ill-requests.tt | 14 +- > .../bootstrap/en/modules/opac-illrequests.tt | 4 + > opac/opac-illrequests.pl | 8 +- > t/db_dependent/Illrequests.t | 53 ++-- > 12 files changed, 325 insertions(+), 203 deletions(-) > create mode 100644 Koha/Exceptions/Ill.pm > >diff --git a/Koha/Exceptions/Ill.pm b/Koha/Exceptions/Ill.pm >new file mode 100644 >index 0000000000..9e1376109b >--- /dev/null >+++ b/Koha/Exceptions/Ill.pm >@@ -0,0 +1,47 @@ >+package Koha::Exceptions::Ill; >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it under the >+# terms of the GNU General Public License as published by the Free Software >+# Foundation; either version 3 of the License, or (at your option) any later >+# version. >+# >+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY >+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR >+# A PARTICULAR PURPOSE. See the GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License along >+# with Koha; if not, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Exception::Class ( >+ >+ 'Koha::Exceptions::Ill' => { >+ description => 'Something went wrong!', >+ }, >+ 'Koha::Exceptions::Ill::InvalidBackendId' => { >+ isa => 'Koha::Exceptions::Ill', >+ description => "Invalid backend name required", >+ } >+); >+ >+=head1 NAME >+ >+Koha::Exceptions::Ill - Base class for ILL exceptions >+ >+=head1 Exceptions >+ >+=head2 Koha::Exceptions::Ill >+ >+Generic Ill exception >+ >+=head2 Koha::Exceptions::Ill::InvalidBackend >+ >+Exception to be used when the required ILL backend is invalid. >+ >+=cut >+ >+1; >diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm >index 5adecb53af..488fa46cd6 100644 >--- a/Koha/Illrequest.pm >+++ b/Koha/Illrequest.pm >@@ -18,16 +18,18 @@ package Koha::Illrequest; > # Koha; if not, write to the Free Software Foundation, Inc., 51 Franklin > # Street, Fifth Floor, Boston, MA 02110-1301 USA. > >+use Modern::Perl; >+ > use Clone 'clone'; > use File::Basename qw/basename/; > use Koha::Database; > use Koha::Email; >+use Koha::Exceptions::Ill; > use Koha::Illrequest; > use Koha::Illrequestattributes; > use Koha::Patron; > use Mail::Sendmail; > use Try::Tiny; >-use Modern::Perl; > > use base qw(Koha::Object); > >@@ -139,13 +141,20 @@ sub load_backend { > my @raw = qw/Koha Illbackends/; # Base Path > > my $backend_name = $backend_id || $self->backend; >- my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load >+ >+ unless ( defined $backend_name && $backend_name ne '' ) { >+ Koha::Exceptions::Ill::InvalidBackendId->throw( >+ "An invalid backend ID was requested ('')"); >+ } >+ >+ my $location = join "/", @raw, $backend_name, "Base.pm"; # File to load > my $backend_class = join "::", @raw, $backend_name, "Base"; # Package name > require $location; > $self->{_my_backend} = $backend_class->new({ config => $self->_config }); > return $self; > } > >+ > =head3 _backend > > my $backend = $abstract->_backend($new_backend); >@@ -468,10 +477,7 @@ Return a list of available backends. > > sub available_backends { > my ( $self ) = @_; >- my $backend_dir = $self->_config->backend_dir; >- my @backends = (); >- @backends = glob "$backend_dir/*" if ( $backend_dir ); >- @backends = map { basename($_) } @backends; >+ my @backends = $self->_config->available_backends; > return \@backends; > } > >diff --git a/Koha/Illrequest/Config.pm b/Koha/Illrequest/Config.pm >index 3bc78d15e9..5c78e80976 100644 >--- a/Koha/Illrequest/Config.pm >+++ b/Koha/Illrequest/Config.pm >@@ -18,6 +18,9 @@ package Koha::Illrequest::Config; > # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > > use Modern::Perl; >+ >+use File::Basename; >+ > use C4::Context; > > =head1 NAME >@@ -100,6 +103,21 @@ sub backend_dir { > return $self->{configuration}->{backend_directory}; > } > >+=head3 available_backends >+ >+Return a list of available backends. >+ >+=cut >+ >+sub available_backends { >+ my ( $self ) = @_; >+ my $backend_dir = $self->backend_dir; >+ my @backends = (); >+ @backends = glob "$backend_dir/*" if ( $backend_dir ); >+ @backends = map { basename($_) } @backends; >+ return \@backends; >+} >+ > =head3 partner_code > > $partner_code = $config->partner_code($new_code); >diff --git a/Koha/Illrequestattribute.pm b/Koha/Illrequestattribute.pm >index 16bc0867a5..cbdee5a3ca 100644 >--- a/Koha/Illrequestattribute.pm >+++ b/Koha/Illrequestattribute.pm >@@ -30,11 +30,11 @@ Koha::Illrequestattribute - Koha Illrequestattribute Object class > > =head1 API > >-=head2 Class Methods >+=head2 Internal methods > > =cut > >-=head3 type >+=head3 _type > > =cut > >diff --git a/about.pl b/about.pl >index 61e81c641f..a7daa3780c 100755 >--- a/about.pl >+++ b/about.pl >@@ -38,6 +38,7 @@ use Koha::Acquisition::Currencies; > use Koha::Patrons; > use Koha::Caches; > use Koha::Config::SysPrefs; >+use Koha::Illrequest::Config; > use C4::Members::Statistics; > > #use Smart::Comments '####'; >@@ -260,6 +261,19 @@ if ( !defined C4::Context->config('use_zebra_facets') ) { > } > } > >+if ( C4::Context->preference('ILLModule') ) { >+ my $warnILLConfiguration = 0; >+ my $available_ill_backends = >+ ( scalar @{ Koha::Illrequest::Config->new->available_backends } > 0 ); >+ >+ if ( !$available_ill_backends ) { >+ $template->param( no_ill_backends => 1 ); >+ $warnILLConfiguration = 1; >+ } >+ >+ $template->param( warnILLConfiguration => $warnILLConfiguration ); >+} >+ > # Sco Patron should not contain any other perms than circulate => self_checkout > if ( C4::Context->preference('WebBasedSelfCheck') > and C4::Context->preference('AutoSelfCheckAllowed') >diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl >index f6572e494d..140eff90c7 100755 >--- a/ill/ill-requests.pl >+++ b/ill/ill-requests.pl >@@ -50,188 +50,190 @@ my ( $template, $patronnumber, $cookie ) = get_template_and_user( { > flagsrequired => { ill => '*' }, > } ); > >-if ( $op eq 'illview' ) { >- # View the details of an ILL >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- >- $template->param( >- request => $request >- ); >- >-} elsif ( $op eq 'create' ) { >- # We're in the process of creating a request >- my $request = Koha::Illrequest->new >- ->load_backend($params->{backend}); >- my $backend_result = $request->backend_create($params); >- $template->param( >- whole => $backend_result, >- request => $request >- ); >- handle_commit_maybe($backend_result, $request); >- >-} elsif ( $op eq 'confirm' ) { >- # Backend 'confirm' method >- # confirm requires a specific request, so first, find it. >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- my $backend_result = $request->backend_confirm($params); >- $template->param( >- whole => $backend_result, >- request => $request, >- ); >- >- # handle special commit rules & update type >- handle_commit_maybe($backend_result, $request); >- >-} elsif ( $op eq 'cancel' ) { >- # Backend 'cancel' method >- # cancel requires a specific request, so first, find it. >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- my $backend_result = $request->backend_cancel($params); >- $template->param( >- whole => $backend_result, >- request => $request, >- ); >- >- # handle special commit rules & update type >- handle_commit_maybe($backend_result, $request); >- >-} elsif ( $op eq 'edit_action' ) { >- # Handle edits to the Illrequest object. >- # (not the Illrequestattributes) >- # We simulate the API for backend requests for uniformity. >- # So, init: >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- if ( !$params->{stage} ) { >- my $backend_result = { >- error => 0, >- status => '', >- message => '', >- method => 'edit_action', >- stage => 'init', >- next => '', >- value => {} >- }; >+# Are we able to actually work? >+my $backends = Koha::Illrequest::Config->new->available_backends; >+my $backends_available = ( scalar @{$backends} > 0 ); >+$template->param( backends_available => $backends_available ); >+ >+if ( $backends_available ) { >+ if ( $op eq 'illview' ) { >+ # View the details of an ILL >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ >+ $template->param( >+ request => $request >+ ); >+ >+ } elsif ( $op eq 'create' ) { >+ # We're in the process of creating a request >+ my $request = Koha::Illrequest->new->load_backend( $params->{backend} ); >+ my $backend_result = $request->backend_create($params); > $template->param( > whole => $backend_result, > request => $request > ); >- } else { >- # Commit: >- # Save the changes >- $request->borrowernumber($params->{borrowernumber}); >- $request->biblio_id($params->{biblio_id}); >- $request->branchcode($params->{branchcode}); >- $request->notesopac($params->{notesopac}); >- $request->notesstaff($params->{notesstaff}); >- $request->store; >- my $backend_result = { >- error => 0, >- status => '', >- message => '', >- method => 'edit_action', >- stage => 'commit', >- next => 'illlist', >- value => {} >- }; > handle_commit_maybe($backend_result, $request); >- } > >-} elsif ( $op eq 'moderate_action' ) { >- # Moderate action is required for an ILL submodule / syspref. >- # Currently still needs to be implemented. >- redirect_to_list(); >+ } elsif ( $op eq 'confirm' ) { >+ # Backend 'confirm' method >+ # confirm requires a specific request, so first, find it. >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ my $backend_result = $request->backend_confirm($params); >+ $template->param( >+ whole => $backend_result, >+ request => $request, >+ ); > >-} elsif ( $op eq 'delete_confirm') { >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ # handle special commit rules & update type >+ handle_commit_maybe($backend_result, $request); >+ >+ } elsif ( $op eq 'cancel' ) { >+ # Backend 'cancel' method >+ # cancel requires a specific request, so first, find it. >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ my $backend_result = $request->backend_cancel($params); >+ $template->param( >+ whole => $backend_result, >+ request => $request, >+ ); > >- $template->param( >- request => $request >- ); >+ # handle special commit rules & update type >+ handle_commit_maybe($backend_result, $request); > >-} elsif ( $op eq 'delete' ) { >+ } elsif ( $op eq 'edit_action' ) { >+ # Handle edits to the Illrequest object. >+ # (not the Illrequestattributes) >+ # We simulate the API for backend requests for uniformity. >+ # So, init: >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ if ( !$params->{stage} ) { >+ my $backend_result = { >+ error => 0, >+ status => '', >+ message => '', >+ method => 'edit_action', >+ stage => 'init', >+ next => '', >+ value => {} >+ }; >+ $template->param( >+ whole => $backend_result, >+ request => $request >+ ); >+ } else { >+ # Commit: >+ # Save the changes >+ $request->borrowernumber($params->{borrowernumber}); >+ $request->biblio_id($params->{biblio_id}); >+ $request->branchcode($params->{branchcode}); >+ $request->notesopac($params->{notesopac}); >+ $request->notesstaff($params->{notesstaff}); >+ $request->store; >+ my $backend_result = { >+ error => 0, >+ status => '', >+ message => '', >+ method => 'edit_action', >+ stage => 'commit', >+ next => 'illlist', >+ value => {} >+ }; >+ handle_commit_maybe($backend_result, $request); >+ } > >- # Check if the request is confirmed, if not, redirect >- # to the confirmation view >- if ($params->{confirmed} == 1) { >- # We simply delete the request... >- my $request = Koha::Illrequests->find( >- $params->{illrequest_id} >- )->delete; >- # ... then return to list view. >+ } elsif ( $op eq 'moderate_action' ) { >+ # Moderate action is required for an ILL submodule / syspref. >+ # Currently still needs to be implemented. > redirect_to_list(); >- } else { >- print $cgi->redirect( >- "/cgi-bin/koha/ill/ill-requests.pl?" . >- "method=delete_confirm&illrequest_id=" . >- $params->{illrequest_id}); >- } > >-} elsif ( $op eq 'mark_completed' ) { >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- my $backend_result = $request->mark_completed($params); >- $template->param( >- whole => $backend_result, >- request => $request, >- ); >- >- # handle special commit rules & update type >- handle_commit_maybe($backend_result, $request); >- >-} elsif ( $op eq 'generic_confirm' ) { >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- $params->{current_branchcode} = C4::Context->mybranch; >- my $backend_result = $request->generic_confirm($params); >- $template->param( >- whole => $backend_result, >- request => $request, >- ); >- >- # handle special commit rules & update type >- handle_commit_maybe($backend_result, $request); >- >-} elsif ( $op eq 'illlist') { >- # Display all current ILLs >- my $requests = $illRequests->search(); >- >- $template->param( >- requests => $requests >- ); >- >- # If we receive a pre-filter, make it available to the template >- my $possible_filters = ['borrowernumber']; >- my $active_filters = []; >- foreach my $filter(@{$possible_filters}) { >- if ($params->{$filter}) { >- push @{$active_filters}, >- { name => $filter, value => $params->{$filter}}; >+ } elsif ( $op eq 'delete_confirm') { >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ >+ $template->param( >+ request => $request >+ ); >+ >+ } elsif ( $op eq 'delete' ) { >+ >+ # Check if the request is confirmed, if not, redirect >+ # to the confirmation view >+ if ($params->{confirmed}) { >+ # We simply delete the request... >+ Koha::Illrequests->find( $params->{illrequest_id} )->delete; >+ # ... then return to list view. >+ redirect_to_list(); >+ } else { >+ print $cgi->redirect( >+ "/cgi-bin/koha/ill/ill-requests.pl?" . >+ "method=delete_confirm&illrequest_id=" . >+ $params->{illrequest_id}); >+ exit; > } >- } >- if (scalar @{$active_filters} > 0) { >+ >+ } elsif ( $op eq 'mark_completed' ) { >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ my $backend_result = $request->mark_completed($params); >+ $template->param( >+ whole => $backend_result, >+ request => $request, >+ ); >+ >+ # handle special commit rules & update type >+ handle_commit_maybe($backend_result, $request); >+ >+ } elsif ( $op eq 'generic_confirm' ) { >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ $params->{current_branchcode} = C4::Context->mybranch; >+ my $backend_result = $request->generic_confirm($params); > $template->param( >- prefilters => $active_filters >+ whole => $backend_result, >+ request => $request, > ); >+ >+ # handle special commit rules & update type >+ handle_commit_maybe($backend_result, $request); >+ >+ } elsif ( $op eq 'illlist') { >+ # Display all current ILLs >+ my $requests = $illRequests->search(); >+ >+ $template->param( >+ requests => $requests >+ ); >+ >+ # If we receive a pre-filter, make it available to the template >+ my $possible_filters = ['borrowernumber']; >+ my $active_filters = []; >+ foreach my $filter(@{$possible_filters}) { >+ if ($params->{$filter}) { >+ push @{$active_filters}, >+ { name => $filter, value => $params->{$filter}}; >+ } >+ } >+ if (scalar @{$active_filters} > 0) { >+ $template->param( >+ prefilters => $active_filters >+ ); >+ } >+ } else { >+ my $request = Koha::Illrequests->find($params->{illrequest_id}); >+ my $backend_result = $request->custom_capability($op, $params); >+ $template->param( >+ whole => $backend_result, >+ request => $request, >+ ); >+ >+ # handle special commit rules & update type >+ handle_commit_maybe($backend_result, $request); > } >-} else { >- my $request = Koha::Illrequests->find($params->{illrequest_id}); >- my $backend_result = $request->custom_capability($op, $params); >- $template->param( >- whole => $backend_result, >- request => $request, >- ); >- >- # handle special commit rules & update type >- handle_commit_maybe($backend_result, $request); > } > >-# Get a list of backends >-my $ir = Koha::Illrequest->new; >- > $template->param( >- backends => $ir->available_backends, >- media => [ "Book", "Article", "Journal" ], >- query_type => $op, >- branches => Koha::Libraries->search->unblessed, >- here_link => "/cgi-bin/koha/ill/ill-requests.pl" >+ backends => $backends, >+ media => [ "Book", "Article", "Journal" ], >+ query_type => $op, >+ branches => Koha::Libraries->search, >+ here_link => "/cgi-bin/koha/ill/ill-requests.pl" > ); > > output_html_with_http_headers( $cgi, $cookie, $template->output ); >@@ -255,4 +257,5 @@ sub handle_commit_maybe { > > sub redirect_to_list { > print $cgi->redirect('/cgi-bin/koha/ill/ill-requests.pl'); >+ exit; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc >index 3f541d9283..b747ee030b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc >@@ -1,7 +1,8 @@ > [% USE Koha %] > [% IF Koha.Preference('ILLModule ') %] > <div id="toolbar" class="btn-toolbar"> >- [% IF backends.size > 1 %] >+ [% IF backends_available %] >+ [% IF backends.size > 1 %] > <div class="dropdown btn-group"> > <button class="btn btn-sm btn-default dropdown-toggle" type="button" id="ill-backend-dropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> > <i class="fa fa-plus"></i> New ILL request <span class="caret"></span> >@@ -12,10 +13,15 @@ > [% END %] > </ul> > </div> >- [% ELSE %] >+ [% ELSE %] > <a id="ill-new" class="btn btn-sm btn-default" href="/cgi-bin/koha/ill/ill-requests.pl?method=create&backend=[% backends.0 %]"> > <i class="fa fa-plus"></i> New ILL request > </a> >+ [% END %] >+ [% ELSE %] >+ <a id="ill-new" class="btn btn-sm btn-default disabled" href=""> >+ <i class="fa fa-plus"></i> New ILL request >+ </a> > [% END %] > <a id="ill-list" class="btn btn-sm btn-default btn-group" href="/cgi-bin/koha/ill/ill-requests.pl"> > <i class="fa fa-list"></i> List requests >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >index a4c0c460ae..42b29743f8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt >@@ -131,7 +131,7 @@ > </div> > > <div id="sysinfo"> >- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || has_ai_issues %] >+ [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || warnIsRootUser || xml_config_warnings.size || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration || has_ai_issues %] > [% IF (warnIsRootUser) %] > <h2>Warning regarding current user</h2> > <p>You are logged in as the database administrative user. This is not recommended because some parts of Koha will not function as expected when using this account.</p> >@@ -176,7 +176,7 @@ > <br/> > [% END %] > >- [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching %] >+ [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron || warnPrefAnonymousPatron_PatronDoesNotExist || warnNoActiveCurrency || QueryParserError || AutoSelfCheckPatronDoesNotHaveSelfCheckPerm || AutoSelfCheckPatronHasTooManyPerm || warnStatisticsFieldsError || warnNoTemplateCaching || warnILLConfiguration %] > <h2>Warnings regarding the system configuration</h2> > <table> > <caption>Preferences and parameters</caption> >@@ -226,6 +226,11 @@ > That will bring a performance boost to enable it. > </td></tr> > [% END %] >+ [% IF warnILLConfiguration %] >+ <tr><th scope="row"><b>Warning</b> </th><td> >+ [% IF no_ill_backends %]The ILL module is enabled, but there are no backends available.[%END %] >+ </td></tr> >+ [% END %] > </table> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >index 96943c19ff..e57115bf05 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >@@ -4,8 +4,7 @@ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › ILL requests ›</title> > [% INCLUDE 'doc-head-close.inc' %] >-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script> >-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> >+<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script> > <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css"> > [% INCLUDE 'datatables.inc' %] > <script type="text/javascript"> >@@ -370,12 +369,11 @@ > > <div id="breadcrumbs"> > <a href="/cgi-bin/koha/mainpage.pl">Home</a> › >+ <a href="/cgi-bin/koha/ill/ill-requests.pl">ILL requests</a> > [% IF query_type == 'create' %] >- <a href=[% parent %]>ILL requests</a> › New request >+ › New request > [% ELSIF query_type == 'status' %] >- <a href=[% parent %]>ILL requests</a> › Status >- [% ELSE %] >- ILL requests >+ › Status > [% END %] > </div> > >@@ -383,6 +381,9 @@ > <div id="bd"> > <div id="yui-main"> > <div id="interlibraryloans" class="yui-b"> >+ [% IF !backends_available %] >+ <div class="dialog message">ILL module configuration problem. Take a look at the <a href="/cgi-bin/koha/about.pl#sysinfo">about page</a></div> >+ [% ELSE %] > [% INCLUDE 'ill-toolbar.inc' %] > > [% IF whole.error %] >@@ -680,6 +681,7 @@ > [% INCLUDE $whole.template %] > > [% END %] >+ [% END %] > </div> > </div> > </div> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >index e0448c18c1..2fe6991a94 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >@@ -48,6 +48,9 @@ > [% ELSE %] > <div class="span12"> > [% END %] >+ [% IF !backends_available %] >+ <div class="alert">ILL module configuration problem. Contact your administrator.</div> >+ [% ELSE %] > <div id="illrequests" class="maincontent"> > [% IF method == 'create' %] > <h2>New Interlibrary loan request</h2> >@@ -193,6 +196,7 @@ > </form> > [% END %] > </div> <!-- / .maincontent --> >+ [% END %] > </div> <!-- / .span10/12 --> > </div> <!-- / .row-fluid --> > </div> <!-- / .container-fluid --> >diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl >index 9ff413adf7..4590284184 100755 >--- a/opac/opac-illrequests.pl >+++ b/opac/opac-illrequests.pl >@@ -24,6 +24,7 @@ use C4::Auth; > use C4::Koha; > use C4::Output; > >+use Koha::Illrequest::Config; > use Koha::Illrequests; > use Koha::Libraries; > use Koha::Patrons; >@@ -48,6 +49,11 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > authnotrequired => ( C4::Context->preference("OpacPublic") ? 1 : 0 ), > }); > >+# Are we able to actually work? >+my $backends = Koha::Illrequest::Config->new->available_backends; >+my $backends_available = ( scalar @{$backends} > 0 ); >+$template->param( backends_available => $backends_available ); >+ > my $op = $params->{'method'} || 'list'; > > if ( $op eq 'list' ) { >@@ -116,8 +122,6 @@ if ( $op eq 'list' ) { > print $query->redirect('/cgi-bin/koha/opac-illrequests.pl?message=2'); > } > } >- >- > } > > $template->param( >diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t >index c778bad5f4..688d6d2881 100644 >--- a/t/db_dependent/Illrequests.t >+++ b/t/db_dependent/Illrequests.t >@@ -357,7 +357,7 @@ subtest 'Backend testing (mocks)' => sub { > > subtest 'Backend core methods' => sub { > >- plan tests => 16; >+ plan tests => 18; > > $schema->storage->txn_begin; > >@@ -371,13 +371,26 @@ subtest 'Backend core methods' => sub { > $config->set_always('getLimitRules', > { default => { count => 0, method => 'active' } }); > >- my $illrq = $builder->build({source => 'Illrequest'}); >- my $illrq_obj = Koha::Illrequests->find($illrq->{illrequest_id}); >- $illrq_obj->_config($config); >- $illrq_obj->_backend($backend); >+ my $illrq = $builder->build_object({ >+ class => 'Koha::Illrequests', >+ value => { backend => undef } >+ }); >+ $illrq->_config($config); >+ >+ # Test error conditions (no backend) >+ throws_ok { $illrq->load_backend; } >+ 'Koha::Exceptions::Ill::InvalidBackendId', >+ 'Exception raised correctly'; >+ >+ throws_ok { $illrq->load_backend(''); } >+ 'Koha::Exceptions::Ill::InvalidBackendId', >+ 'Exception raised correctly'; >+ >+ # Now load the mocked backend >+ $illrq->_backend($backend); > > # expandTemplate: >- is_deeply($illrq_obj->expandTemplate({ test => 1, method => "bar" }), >+ is_deeply($illrq->expandTemplate({ test => 1, method => "bar" }), > { > test => 1, > method => "bar", >@@ -394,7 +407,7 @@ subtest 'Backend core methods' => sub { > { stage => 'commit', method => 'create' }); > # Test Copyright Clearance > t::lib::Mocks::mock_preference("ILLModuleCopyrightClearance", "Test Copyright Clearance."); >- is_deeply($illrq_obj->backend_create({test => 1}), >+ is_deeply($illrq->backend_create({test => 1}), > { > error => 0, > status => '', >@@ -408,7 +421,7 @@ subtest 'Backend core methods' => sub { > "Backend create: copyright clearance."); > t::lib::Mocks::mock_preference("ILLModuleCopyrightClearance", ""); > # Test non-commit >- is_deeply($illrq_obj->backend_create({test => 1}), >+ is_deeply($illrq->backend_create({test => 1}), > { > stage => 'bar', method => 'create', > template => "/tmp/Mock/intra-includes/create.inc", >@@ -416,28 +429,28 @@ subtest 'Backend core methods' => sub { > }, > "Backend create: arbitrary stage."); > # Test commit >- is_deeply($illrq_obj->backend_create({test => 1}), >+ is_deeply($illrq->backend_create({test => 1}), > { > stage => 'commit', method => 'create', permitted => 0, > template => "/tmp/Mock/intra-includes/create.inc", > opac_template => "/tmp/Mock/opac-includes/create.inc", > }, > "Backend create: arbitrary stage, not permitted."); >- is($illrq_obj->status, "QUEUED", "Backend create: queued if restricted."); >+ is($illrq->status, "QUEUED", "Backend create: queued if restricted."); > $config->set_always('getLimitRules', {}); >- $illrq_obj->status('NEW'); >- is_deeply($illrq_obj->backend_create({test => 1}), >+ $illrq->status('NEW'); >+ is_deeply($illrq->backend_create({test => 1}), > { > stage => 'commit', method => 'create', permitted => 1, > template => "/tmp/Mock/intra-includes/create.inc", > opac_template => "/tmp/Mock/opac-includes/create.inc", > }, > "Backend create: arbitrary stage, permitted."); >- is($illrq_obj->status, "NEW", "Backend create: not-queued."); >+ is($illrq->status, "NEW", "Backend create: not-queued."); > > # backend_renew > $backend->set_series('renew', { stage => 'bar', method => 'renew' }); >- is_deeply($illrq_obj->backend_renew({test => 1}), >+ is_deeply($illrq->backend_renew({test => 1}), > { > stage => 'bar', method => 'renew', > template => "/tmp/Mock/intra-includes/renew.inc", >@@ -447,7 +460,7 @@ subtest 'Backend core methods' => sub { > > # backend_cancel > $backend->set_series('cancel', { stage => 'bar', method => 'cancel' }); >- is_deeply($illrq_obj->backend_cancel({test => 1}), >+ is_deeply($illrq->backend_cancel({test => 1}), > { > stage => 'bar', method => 'cancel', > template => "/tmp/Mock/intra-includes/cancel.inc", >@@ -457,7 +470,7 @@ subtest 'Backend core methods' => sub { > > # backend_update_status > $backend->set_series('update_status', { stage => 'bar', method => 'update_status' }); >- is_deeply($illrq_obj->backend_update_status({test => 1}), >+ is_deeply($illrq->backend_update_status({test => 1}), > { > stage => 'bar', method => 'update_status', > template => "/tmp/Mock/intra-includes/update_status.inc", >@@ -467,7 +480,7 @@ subtest 'Backend core methods' => sub { > > # backend_confirm > $backend->set_series('confirm', { stage => 'bar', method => 'confirm' }); >- is_deeply($illrq_obj->backend_confirm({test => 1}), >+ is_deeply($illrq->backend_confirm({test => 1}), > { > stage => 'bar', method => 'confirm', > template => "/tmp/Mock/intra-includes/confirm.inc", >@@ -489,7 +502,7 @@ subtest 'Backend core methods' => sub { > source => 'Borrower', > value => { categorycode => "ILLTSTLIB" }, > }); >- my $gen_conf = $illrq_obj->generic_confirm({ >+ my $gen_conf = $illrq->generic_confirm({ > current_branchcode => $illbrn->{branchcode} > }); > isnt(index($gen_conf->{value}->{draft}->{body}, $backend->metadata->{Test}), -1, >@@ -502,13 +515,13 @@ subtest 'Backend core methods' => sub { > "Generic confirm: partner 2 is correct." > ); > >- dies_ok { $illrq_obj->generic_confirm({ >+ dies_ok { $illrq->generic_confirm({ > current_branchcode => $illbrn->{branchcode}, > stage => 'draft' > }) } > "Generic confirm: missing to dies OK."; > >- dies_ok { $illrq_obj->generic_confirm({ >+ dies_ok { $illrq->generic_confirm({ > current_branchcode => $illbrn->{branchcode}, > partners => $partner1->{email}, > stage => 'draft' >-- >2.15.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 7317
:
59893
|
59894
|
59895
|
59920
|
60485
|
60486
|
60487
|
60488
|
63081
|
63082
|
63083
|
63084
|
63085
|
63086
|
63087
|
63088
|
63089
|
63090
|
63113
|
63175
|
63176
|
63354
|
63421
|
63472
|
63475
|
65469
|
65470
|
65471
|
65472
|
65473
|
65474
|
65475
|
65476
|
66266
|
67242
|
67243
|
67244
|
67245
|
67246
|
67247
|
67248
|
67249
|
67250
|
67251
|
67252
|
67253
|
67254
|
67255
|
67256
|
67257
|
67258
|
67259
|
67260
|
67261
|
67262
|
67263
|
67264
|
67281
|
67282
|
67283
|
67284
|
67285
|
67286
|
67287
|
67288
|
67289
|
67290
|
67291
|
67292
|
67293
|
67294
|
67295
|
67296
|
67297
|
67298
|
67299
|
67300
|
67301
|
67302
|
67303
|
68185
|
68186
|
68328
|
68391
|
68406
|
68407
|
68408
|
68409
|
68418
|
68444
|
68445
|
68483
|
68484
|
68485
|
68487
|
68516
|
68517
|
68518
|
68519
|
68520
|
68521
|
68522
|
68523
|
68524
|
68525
|
68542
|
68543
|
68544
|
68545
|
68546
|
68547
|
68548
|
68549
|
68550
|
68551
|
68552
|
68558
|
68559
|
68560
|
68561
|
68562
|
68563
|
68564
|
68565
|
68566
|
68567
|
68858
|
68874
|
68877
|
68878
|
68885
|
68886
|
68921
|
68922
|
68926
|
68927
|
68928
|
68929
| 68931 |
68932
|
68933
|
68988
|
68989
|
68999
|
69000
|
69006
|
69008
|
69009
|
69012
|
69014
|
69044
|
69045
|
69046
|
69056
|
69059
|
69060
|
69061
|
69063
|
69064
|
69065
|
69066
|
69069
|
69070
|
69071
|
69074