From 66727e6c688f5cc61243c8e789ff82bab5b98fae Mon Sep 17 00:00:00 2001 From: Magnus Enger Date: Tue, 31 Oct 2017 12:07:00 +0000 Subject: [PATCH] Bug 7317: QA followup This fixes some of the issues reported by the QA script, but not all. Signed-off-by: Jonathan Druart --- Koha/Illrequest.pm | 70 ++++++++++++++++--- Koha/Illrequestattributes.pm | 6 +- Koha/Illrequests.pm | 8 ++- Koha/REST/V1/Illrequests.pm | 12 ++++ .../prog/en/modules/ill/ill-requests.tt | 9 +-- .../en/modules/opac-results-grouped.tt | 9 +-- .../bootstrap/en/modules/opac-results.tt | 9 +-- t/db_dependent/Illrequestattributes.t | 23 +++--- t/db_dependent/Illrequests.t | 23 +++--- 9 files changed, 106 insertions(+), 63 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 2b34b88938..5adecb53af 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -18,8 +18,6 @@ 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; @@ -29,6 +27,7 @@ use Koha::Illrequestattributes; use Koha::Patron; use Mail::Sendmail; use Try::Tiny; +use Modern::Perl; use base qw(Koha::Object); @@ -59,6 +58,8 @@ TODO: All methods should return a hashref in the following format: +=over + =item * error This should be set to 1 if an error was encountered. @@ -75,7 +76,7 @@ The message is a free text field that can be passed on to the end user. The value returned by the method. -=over +=back =head2 Interface Status Messages @@ -100,8 +101,12 @@ the API. The interface's request method returned saying that the desired item is not available for request. +=back + =head2 Class methods +=head3 illrequestattributes + =cut sub illrequestattributes { @@ -111,6 +116,10 @@ sub illrequestattributes { ); } +=head3 patron + +=cut + sub patron { my ( $self ) = @_; return Koha::Patron->_new_from_dbic( @@ -118,14 +127,20 @@ sub patron { ); } +=head3 load_backend + +Require "Base.pm" from the relevant ILL backend. + +=cut + sub load_backend { my ( $self, $backend_id ) = @_; my @raw = qw/Koha Illbackends/; # Base Path my $backend_name = $backend_id || $self->backend; - $location = join "/", @raw, $backend_name, "Base.pm"; # File to load - $backend_class = join "::", @raw, $backend_name, "Base"; # Package name + 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; @@ -342,7 +357,7 @@ sub _status_graph_union { my $status_graph = clone($core_status_graph); foreach my $backend_status_key ( keys %{$backend_status_graph} ) { - $backend_status = $backend_status_graph->{$backend_status_key}; + my $backend_status = $backend_status_graph->{$backend_status_key}; # Add to new status graph $status_graph->{$backend_status_key} = $backend_status; # Update all core methods' next_actions. @@ -445,15 +460,27 @@ sub custom_capability { return 0; } +=head3 available_backends + +Return a list of available backends. + +=cut + sub available_backends { my ( $self ) = @_; my $backend_dir = $self->_config->backend_dir; my @backends = (); - @backends = <$backend_dir/*> if ( $backend_dir ); + @backends = glob "$backend_dir/*" if ( $backend_dir ); @backends = map { basename($_) } @backends; return \@backends; } +=head3 available_actions + +Return a list of available actions. + +=cut + sub available_actions { my ( $self ) = @_; my $current_action = $self->capabilities($self->status); @@ -462,6 +489,12 @@ sub available_actions { return \@available_actions; } +=head3 mark_completed + +Mark a request as completed (status = COMP). + +=cut + sub mark_completed { my ( $self ) = @_; $self->status('COMP')->store; @@ -475,12 +508,23 @@ sub mark_completed { }; } +=head2 backend_confirm + +Confirm a request. The backend handles setting of mandatory fields in the commit stage: + +=over + +=item * orderid + +=item * accessurl, cost (if available). + +=back + +=cut + sub backend_confirm { my ( $self, $params ) = @_; - # The backend handles setting of mandatory fields in the commit stage: - # - orderid - # - accessurl, cost (if available). my $response = $self->_backend->confirm({ request => $self, other => $params, @@ -488,6 +532,10 @@ sub backend_confirm { return $self->expandTemplate($response); } +=head3 backend_update_status + +=cut + sub backend_update_status { my ( $self, $params ) = @_; return $self->expandTemplate($self->_backend->update_status($params)); @@ -739,7 +787,7 @@ sub _limit_counter { } else { # assume 'active' # XXX: This status list is ugly. There should be a method in config # to return these. - $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } }; + my $where = { status => { -not_in => [ 'QUEUED', 'COMP' ] } }; $resultset = Koha::Illrequests->search({ %{$target}, %{$where} }); } diff --git a/Koha/Illrequestattributes.pm b/Koha/Illrequestattributes.pm index e05fa6e478..1d87a90154 100644 --- a/Koha/Illrequestattributes.pm +++ b/Koha/Illrequestattributes.pm @@ -32,8 +32,6 @@ Koha::Illrequestattributes - Koha Illrequestattributes Object class =head2 Class Methods -=cut - =head3 type =cut @@ -42,6 +40,10 @@ sub _type { return 'Illrequestattribute'; } +=head3 object_class + +=cut + sub object_class { return 'Koha::Illrequestattribute'; } diff --git a/Koha/Illrequests.pm b/Koha/Illrequests.pm index 85cc711e60..f09660ec74 100644 --- a/Koha/Illrequests.pm +++ b/Koha/Illrequests.pm @@ -33,9 +33,7 @@ Koha::Illrequests - Koha Illrequests Object class =head2 Class Methods -=cut - -=head3 type +=head3 _type =cut @@ -43,6 +41,10 @@ sub _type { return 'Illrequest'; } +=head3 object_class + +=cut + sub object_class { return 'Koha::Illrequest'; } diff --git a/Koha/REST/V1/Illrequests.pm b/Koha/REST/V1/Illrequests.pm index 947fb7972f..6e3eace01d 100644 --- a/Koha/REST/V1/Illrequests.pm +++ b/Koha/REST/V1/Illrequests.pm @@ -22,6 +22,18 @@ use Mojo::Base 'Mojolicious::Controller'; use Koha::Illrequests; use Koha::Libraries; +=head1 NAME + +Koha::REST::V1::Illrequests + +=head2 Operations + +=head3 list + +Return a list of ILL requests, after applying filters. + +=cut + sub list { my $c = shift->openapi->valid_input or return; 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 6d1b9a7fec..96943c19ff 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 @@ -348,7 +348,6 @@ filterNames.forEach(function(thisFilter) { var filterName = toColumnName(thisFilter) + ':name'; var regex = '^'+filters[thisFilter]+'$'; - console.log(regex); myTable.columns(filterName).search(regex, true, false); }); myTable.draw(); @@ -586,13 +585,9 @@
Borrower: - [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" - _ "?borrowernumber=" _ request.patron.borrowernumber %] + [% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %] - [% request.patron.firstname _ " " - _ request.patron.surname _ " [" - _ request.patron.cardnumber - _ "]" %] + [% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" %]
diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt index eaa20b30a4..f24c04c69a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results-grouped.tt @@ -253,14 +253,7 @@ href="/cgi-bin/koha/opac-rss.pl?[% query_cgi %][% limit_cgi |html %]" /> [% INCLUDE 'page-numbers.inc' %] [% END # / IF total %] - [% IF - Koha.Preference( 'suggestion' ) == 1 && - ( - Koha.Preference( 'AnonSuggestions' ) == 1 || - loggedinusername || - Koha.Preference( 'ILLModule' ) == 1 - ) - %] + [% IF Koha.Preference( 'suggestion' ) == 1 && ( Koha.Preference( 'AnonSuggestions' ) == 1 || loggedinusername || Koha.Preference( 'ILLModule' ) == 1 ) %]
Not finding what you're looking for?
    diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt index 11cf98e317..085f6c5648 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt @@ -562,14 +562,7 @@ [% END # / IF total %] - [% IF - Koha.Preference( 'suggestion' ) == 1 && - ( - Koha.Preference( 'AnonSuggestions' ) == 1 || - loggedinusername || - Koha.Preference( 'ILLModule' ) == 1 - ) - %] + [% IF Koha.Preference( 'suggestion' ) == 1 && ( Koha.Preference( 'AnonSuggestions' ) == 1 || loggedinusername || Koha.Preference( 'ILLModule' ) == 1 ) %]
    Not finding what you're looking for?
      diff --git a/t/db_dependent/Illrequestattributes.t b/t/db_dependent/Illrequestattributes.t index ceb0474264..0eb5d5c107 100644 --- a/t/db_dependent/Illrequestattributes.t +++ b/t/db_dependent/Illrequestattributes.t @@ -1,20 +1,19 @@ #!/usr/bin/perl -# + # 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 2 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. +# 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. # -# 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 +# 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, see . use Modern::Perl; diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t index b65dc0810e..c778bad5f4 100644 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Illrequests.t @@ -1,20 +1,19 @@ #!/usr/bin/perl -# + # 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 2 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. +# 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. # -# 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 +# 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, see . use Modern::Perl; -- 2.39.5