Skip to content

Commit

Permalink
Bug 7317: QA followup
Browse files Browse the repository at this point in the history
This fixes some of the issues reported by the QA script, but not all.

Signed-off-by: Jonathan Druart <[email protected]>
  • Loading branch information
MagnusEnger authored and joubu committed Nov 9, 2017
1 parent 9fafb8b commit 66727e6
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 63 deletions.
70 changes: 59 additions & 11 deletions Koha/Illrequest.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -29,6 +27,7 @@ use Koha::Illrequestattributes;
use Koha::Patron;
use Mail::Sendmail;
use Try::Tiny;
use Modern::Perl;

use base qw(Koha::Object);

Expand Down Expand Up @@ -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.
Expand All @@ -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
Expand All @@ -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 {
Expand All @@ -111,21 +116,31 @@ sub illrequestattributes {
);
}

=head3 patron
=cut

sub patron {
my ( $self ) = @_;
return Koha::Patron->_new_from_dbic(
scalar $self->_result->borrowernumber
);
}

=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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand All @@ -475,19 +508,34 @@ 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,
});
return $self->expandTemplate($response);
}

=head3 backend_update_status
=cut

sub backend_update_status {
my ( $self, $params ) = @_;
return $self->expandTemplate($self->_backend->update_status($params));
Expand Down Expand Up @@ -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} });
}

Expand Down
6 changes: 4 additions & 2 deletions Koha/Illrequestattributes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ Koha::Illrequestattributes - Koha Illrequestattributes Object class
=head2 Class Methods
=cut

=head3 type
=cut
Expand All @@ -42,6 +40,10 @@ sub _type {
return 'Illrequestattribute';
}

=head3 object_class
=cut

sub object_class {
return 'Koha::Illrequestattribute';
}
Expand Down
8 changes: 5 additions & 3 deletions Koha/Illrequests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,18 @@ Koha::Illrequests - Koha Illrequests Object class
=head2 Class Methods
=cut

=head3 type
=head3 _type
=cut

sub _type {
return 'Illrequest';
}

=head3 object_class
=cut

sub object_class {
return 'Koha::Illrequest';
}
Expand Down
12 changes: 12 additions & 0 deletions Koha/REST/V1/Illrequests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 2 additions & 7 deletions koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -586,13 +585,9 @@
</div>
<div class="borrowernumber">
<span class="label borrowernumber">Borrower:</span>
[% borrowerlink = "/cgi-bin/koha/members/moremember.pl"
_ "?borrowernumber=" _ request.patron.borrowernumber %]
[% borrowerlink = "/cgi-bin/koha/members/moremember.pl" _ "?borrowernumber=" _ request.patron.borrowernumber %]
<a href="[% borrowerlink %]" title="View borrower details">
[% request.patron.firstname _ " "
_ request.patron.surname _ " ["
_ request.patron.cardnumber
_ "]" %]
[% request.patron.firstname _ " " _ request.patron.surname _ " [" _ request.patron.cardnumber _ "]" %]
</a>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) %]
<div class="suggestion">
Not finding what you're looking for?
<ul>
Expand Down
9 changes: 1 addition & 8 deletions koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) %]
<div class="suggestion">
Not finding what you're looking for?
<ul>
Expand Down
23 changes: 11 additions & 12 deletions t/db_dependent/Illrequestattributes.t
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses>.

use Modern::Perl;

Expand Down
23 changes: 11 additions & 12 deletions t/db_dependent/Illrequests.t
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses>.

use Modern::Perl;

Expand Down

0 comments on commit 66727e6

Please sign in to comment.