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> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
66727e6c68
commit
06f9e5fe3a
|
|
@ -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;
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ Koha::Illrequestattribute - Koha Illrequestattribute Object class
|
|||
|
||||
=head1 API
|
||||
|
||||
=head2 Class Methods
|
||||
=head2 Internal methods
|
||||
|
||||
=cut
|
||||
|
||||
=head3 type
|
||||
=head3 _type
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
14
about.pl
14
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')
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
# 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 );
|
||||
|
||||
$template->param(
|
||||
request => $request
|
||||
);
|
||||
if ( $backends_available ) {
|
||||
if ( $op eq 'illview' ) {
|
||||
# View the details of an ILL
|
||||
my $request = Koha::Illrequests->find($params->{illrequest_id});
|
||||
|
||||
} 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);
|
||||
$template->param(
|
||||
request => $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 => {}
|
||||
};
|
||||
} 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 => {}
|
||||
};
|
||||
$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 '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;
|
||||
}
|
||||
|
||||
} 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}};
|
||||
}
|
||||
}
|
||||
if (scalar @{$active_filters} > 0) {
|
||||
$template->param(
|
||||
prefilters => $active_filters
|
||||
);
|
||||
}
|
||||
} 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 => {}
|
||||
};
|
||||
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);
|
||||
}
|
||||
|
||||
} 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 '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} == 1) {
|
||||
# We simply delete the request...
|
||||
my $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});
|
||||
}
|
||||
|
||||
} 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}};
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
# 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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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 %]
|
||||
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 -->
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
|
|||
Loading…
Reference in New Issue