View | Details | Raw Unified | Return to bug 35581
Collapse All | Expand All

(-)a/Koha/ILL/Backend.pm (-2 / +2 lines)
Lines 35-41 New ILL Backend Link Here
35
35
36
sub new {
36
sub new {
37
    my $class = shift;
37
    my $class = shift;
38
    my $self = {};
38
    my $self  = {};
39
    return bless $self, $class;
39
    return bless $self, $class;
40
}
40
}
41
41
Lines 117-123 sub embed { Link Here
117
117
118
    foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
118
    foreach my $embed_req ( split /\s*,\s*/, $embed_header ) {
119
        if ( $embed_req eq 'statuses+strings' ) {
119
        if ( $embed_req eq 'statuses+strings' ) {
120
            $return_embed->{statuses} = $self->existing_statuses( $backend_id );
120
            $return_embed->{statuses} = $self->existing_statuses($backend_id);
121
        }
121
        }
122
    }
122
    }
123
    return $return_embed;
123
    return $return_embed;
(-)a/Koha/ILL/Request/SupplierUpdateProcessor.pm (-3 / +3 lines)
Lines 51-61 Create a new Koha::ILL::Request::SupplierUpdateProcessor object . Link Here
51
51
52
sub new {
52
sub new {
53
    my ( $class, $target_source_type, $target_source_name, $processor_name ) = @_;
53
    my ( $class, $target_source_type, $target_source_name, $processor_name ) = @_;
54
    my $self  = {};
54
    my $self = {};
55
55
56
    $self->{target_source_type} = $target_source_type;
56
    $self->{target_source_type} = $target_source_type;
57
    $self->{target_source_name} = $target_source_name;
57
    $self->{target_source_name} = $target_source_name;
58
    $self->{name} = $processor_name;
58
    $self->{name}               = $processor_name;
59
59
60
    bless $self, $class;
60
    bless $self, $class;
61
61
Lines 71-77 Runs the processor Link Here
71
=cut
71
=cut
72
72
73
sub run {
73
sub run {
74
    my ( $self ) = @_;
74
    my ($self) = @_;
75
    my ( $package, $filename ) = caller;
75
    my ( $package, $filename ) = caller;
76
    warn __PACKAGE__ . " run should only be invoked by a subclass\n";
76
    warn __PACKAGE__ . " run should only be invoked by a subclass\n";
77
}
77
}
(-)a/Koha/ILL/Request/Workflow/TypeDisclaimer.pm (-22 / +25 lines)
Lines 54-80 sub show_type_disclaimer { Link Here
54
54
55
    my $disc_sys_pref = $self->_get_type_disclaimer_sys_pref;
55
    my $disc_sys_pref = $self->_get_type_disclaimer_sys_pref;
56
56
57
    my $disc_info =
57
    my $disc_info = $self->_get_type_disclaimer_info(
58
      $self->_get_type_disclaimer_info( $self->_get_type_disclaimer_sys_pref,
58
        $self->_get_type_disclaimer_sys_pref,
59
        $self->{metadata}->{type} );
59
        $self->{metadata}->{type}
60
    );
60
61
61
    return
62
    return
62
63
63
      # ILLModuleDisclaimerByType contains correct YAML
64
        # ILLModuleDisclaimerByType contains correct YAML
64
      %{$disc_sys_pref}
65
        %{$disc_sys_pref}
65
66
66
      # Check that we have info to display for this type
67
        # Check that we have info to display for this type
67
      && $disc_info
68
        && $disc_info
68
69
69
      # ILLModuleDisclaimerByType contains at least 'all'
70
        # ILLModuleDisclaimerByType contains at least 'all'
70
      && $disc_sys_pref->{all}
71
        && $disc_sys_pref->{all}
71
72
72
      # Type disclaimer has not yet been submitted
73
        # Type disclaimer has not yet been submitted
73
      && !$self->{metadata}->{type_disclaimer_submitted}
74
        && !$self->{metadata}->{type_disclaimer_submitted}
74
75
75
     # The form has been submitted and the backend is able to create the request
76
        # The form has been submitted and the backend is able to create the request
76
      && $request->_backend_capability( 'can_create_request',
77
        && $request->_backend_capability(
77
        $self->{metadata} );
78
        'can_create_request',
79
        $self->{metadata}
80
        );
78
}
81
}
79
82
80
=head3 type_disclaimer_template_params
83
=head3 type_disclaimer_template_params
Lines 90-101 Given $params, return true if type disclaimer should be rendered Link Here
90
sub type_disclaimer_template_params {
93
sub type_disclaimer_template_params {
91
    my ( $self, $params ) = @_;
94
    my ( $self, $params ) = @_;
92
95
93
    my $disc_info =
96
    my $disc_info = $self->_get_type_disclaimer_info(
94
      $self->_get_type_disclaimer_info( $self->_get_type_disclaimer_sys_pref,
97
        $self->_get_type_disclaimer_sys_pref,
95
        $params->{type} );
98
        $params->{type}
99
    );
96
100
97
    $params->{method} = 'typedisclaimer' if $self->{ui_context} eq 'staff';
101
    $params->{method} = 'typedisclaimer' if $self->{ui_context} eq 'staff';
98
    delete $params->{stage}              if $self->{ui_context} eq 'staff';
102
    delete $params->{stage} if $self->{ui_context} eq 'staff';
99
103
100
    return (
104
    return (
101
        whole      => $params,
105
        whole      => $params,
Lines 106-112 sub type_disclaimer_template_params { Link Here
106
            illrequestsview => 1,
110
            illrequestsview => 1,
107
            message         => $params->{message},
111
            message         => $params->{message},
108
            method          => 'typedisclaimer',
112
            method          => 'typedisclaimer',
109
          )
113
            )
110
        : ()
114
        : ()
111
    );
115
    );
112
}
116
}
Lines 154-160 sub _get_type_disclaimer_info { Link Here
154
    my ( $self, $disc_sys_pref, $type ) = @_;
158
    my ( $self, $disc_sys_pref, $type ) = @_;
155
159
156
    my @matching_request_type =
160
    my @matching_request_type =
157
      map ( $_ eq $type ? $_ : (), keys %$disc_sys_pref );
161
        map ( $_ eq $type ? $_ : (), keys %$disc_sys_pref );
158
162
159
    my $disc_info = undef;
163
    my $disc_info = undef;
160
    if ( scalar @matching_request_type ) {
164
    if ( scalar @matching_request_type ) {
Lines 162-169 sub _get_type_disclaimer_info { Link Here
162
166
163
        $disc_info->{text}   = $disc_sys_pref->{$type}->{text};
167
        $disc_info->{text}   = $disc_sys_pref->{$type}->{text};
164
        $disc_info->{av_cat} = $disc_sys_pref->{$type}->{av_category_code};
168
        $disc_info->{av_cat} = $disc_sys_pref->{$type}->{av_category_code};
165
    }
169
    } elsif ( $disc_sys_pref->{all} ) {
166
    elsif ( $disc_sys_pref->{all} ) {
167
        $disc_info->{text}   = $disc_sys_pref->{all}->{text};
170
        $disc_info->{text}   = $disc_sys_pref->{all}->{text};
168
        $disc_info->{av_cat} = $disc_sys_pref->{all}->{av_category_code};
171
        $disc_info->{av_cat} = $disc_sys_pref->{all}->{av_category_code};
169
    }
172
    }
(-)a/Koha/REST/V1/ILL/Backends.pm (-17 / +17 lines)
Lines 2-19 package Koha::REST::V1::ILL::Backends; Link Here
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
5
# Koha is free software; you can redistribute it and/or modify it
6
# terms of the GNU General Public License as published by the Free Software
6
# under the terms of the GNU General Public License as published by
7
# Foundation; either version 3 of the License, or (at your option) any later
7
# the Free Software Foundation; either version 3 of the License, or
8
# version.
8
# (at your option) any later version.
9
#
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
10
# Koha is distributed in the hope that it will be useful, but
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
13
#
14
#
14
# You should have received a copy of the GNU General Public License along
15
# You should have received a copy of the GNU General Public License
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
Lines 45-54 sub list { Link Here
45
    foreach my $b (@$backends) {
45
    foreach my $b (@$backends) {
46
        my $backend = Koha::ILL::Request->new->load_backend($b);
46
        my $backend = Koha::ILL::Request->new->load_backend($b);
47
        push @data,
47
        push @data,
48
          {
48
            {
49
            ill_backend_id => $b,
49
            ill_backend_id => $b,
50
            capabilities   => $backend->capabilities,
50
            capabilities   => $backend->capabilities,
51
          };
51
            };
52
    }
52
    }
53
    return $c->render( status => 200, openapi => \@data );
53
    return $c->render( status => 200, openapi => \@data );
54
}
54
}
Lines 73-81 sub get { Link Here
73
73
74
        my $backend_module = Koha::ILL::Backend->new;
74
        my $backend_module = Koha::ILL::Backend->new;
75
75
76
        my $embed =
76
        my $embed = $backend_module->embed(
77
          $backend_module->embed( $backend_id,
77
            $backend_id,
78
            $c->req->headers->header('x-koha-embed') );
78
            $c->req->headers->header('x-koha-embed')
79
        );
79
80
80
        #TODO: We need a to_api method in Koha::ILL::Backend
81
        #TODO: We need a to_api method in Koha::ILL::Backend
81
        my $return = {
82
        my $return = {
Lines 87-94 sub get { Link Here
87
            status  => 200,
88
            status  => 200,
88
            openapi => $embed ? { %$return, %$embed } : $return,
89
            openapi => $embed ? { %$return, %$embed } : $return,
89
        );
90
        );
90
    }
91
    } catch {
91
    catch {
92
        return $c->render(
92
        return $c->render(
93
            status  => 404,
93
            status  => 404,
94
            openapi => { error => "ILL backend does not exist" }
94
            openapi => { error => "ILL backend does not exist" }
(-)a/t/db_dependent/Koha/ILL/Batch/Statuses.t (-4 / +4 lines)
Lines 193-202 my $status5 = Koha::ILL::Batch::Status->new( Link Here
193
$status5->create_and_log;
193
$status5->create_and_log;
194
my $batch = Koha::ILL::Batch->new(
194
my $batch = Koha::ILL::Batch->new(
195
    {
195
    {
196
        name       => "My test batch",
196
        name        => "My test batch",
197
        patron_id  => $patron->borrowernumber,
197
        patron_id   => $patron->borrowernumber,
198
        library_id => $library->branchcode,
198
        library_id  => $library->branchcode,
199
        backend    => "TEST",
199
        backend     => "TEST",
200
        status_code => $status5->code
200
        status_code => $status5->code
201
    }
201
    }
202
);
202
);
(-)a/t/db_dependent/Koha/ILL/Batches.t (-1 / +1 lines)
Lines 54-60 my $branch = $builder->build( { source => 'Branch' } ); Link Here
54
my $illbatch = $builder->build_object(
54
my $illbatch = $builder->build_object(
55
    {
55
    {
56
        class => 'Koha::ILL::Batches',
56
        class => 'Koha::ILL::Batches',
57
        value  => {
57
        value => {
58
            name       => "My test batch",
58
            name       => "My test batch",
59
            backend    => "Mock",
59
            backend    => "Mock",
60
            patron_id  => $librarian->{borrowernumber},
60
            patron_id  => $librarian->{borrowernumber},
(-)a/t/db_dependent/Koha/ILL/Comments.t (-18 / +21 lines)
Lines 30-36 use Test::MockModule; Link Here
30
30
31
use Test::More tests => 9;
31
use Test::More tests => 9;
32
32
33
my $schema = Koha::Database->new->schema;
33
my $schema  = Koha::Database->new->schema;
34
my $builder = t::lib::TestBuilder->new;
34
my $builder = t::lib::TestBuilder->new;
35
use_ok('Koha::ILL::Comment');
35
use_ok('Koha::ILL::Comment');
36
use_ok('Koha::ILL::Comments');
36
use_ok('Koha::ILL::Comments');
Lines 40-68 $schema->storage->txn_begin; Link Here
40
Koha::ILL::Requests->search->delete;
40
Koha::ILL::Requests->search->delete;
41
41
42
# Create a patron
42
# Create a patron
43
my $patron = $builder->build({ source => 'Borrower' });
43
my $patron = $builder->build( { source => 'Borrower' } );
44
44
45
# Create an ILL request
45
# Create an ILL request
46
my $illrq = $builder->build({
46
my $illrq = $builder->build(
47
    source => 'Illrequest',
47
    {
48
    value => { borrowernumber => $patron->{borrowernumber} }
48
        source => 'Illrequest',
49
});
49
        value  => { borrowernumber => $patron->{borrowernumber} }
50
my $illrq_obj = Koha::ILL::Requests->find($illrq->{illrequest_id});
50
    }
51
);
52
my $illrq_obj = Koha::ILL::Requests->find( $illrq->{illrequest_id} );
51
isa_ok( $illrq_obj, 'Koha::ILL::Request' );
53
isa_ok( $illrq_obj, 'Koha::ILL::Request' );
52
54
53
# Create a librarian
55
# Create a librarian
54
my $librarian = $builder->build({ source => 'Borrower' });
56
my $librarian = $builder->build( { source => 'Borrower' } );
55
57
56
# Create a comment and tie it to the request and the librarian
58
# Create a comment and tie it to the request and the librarian
57
my $comment_text = 'xyz';
59
my $comment_text = 'xyz';
58
my $illcomment = $builder->build({
60
my $illcomment   = $builder->build(
59
    source => 'Illcomment',
61
    {
60
    value => {
62
        source => 'Illcomment',
61
        illrequest_id  => $illrq_obj->illrequest_id,
63
        value  => {
62
        borrowernumber => $librarian->{borrowernumber},
64
            illrequest_id  => $illrq_obj->illrequest_id,
63
        comment        => $comment_text,
65
            borrowernumber => $librarian->{borrowernumber},
66
            comment        => $comment_text,
67
        }
64
    }
68
    }
65
});
69
);
66
70
67
# Get all the comments
71
# Get all the comments
68
my $comments = $illrq_obj->illcomments;
72
my $comments = $illrq_obj->illcomments;
Lines 76-83 isa_ok( $comment, 'Koha::ILL::Comment', "Illcomment" ); Link Here
76
80
77
# Check the different data in the comment
81
# Check the different data in the comment
78
is( $comment->illrequest_id,  $illrq_obj->illrequest_id,    'illrequest_id getter works' );
82
is( $comment->illrequest_id,  $illrq_obj->illrequest_id,    'illrequest_id getter works' );
79
is( $comment->borrowernumber, $librarian->{borrowernumber}, 'borrowernumber getter works');
83
is( $comment->borrowernumber, $librarian->{borrowernumber}, 'borrowernumber getter works' );
80
is( $comment->comment,        $comment_text,                'comment getter works');
84
is( $comment->comment,        $comment_text,                'comment getter works' );
81
85
82
$illrq_obj->delete;
86
$illrq_obj->delete;
83
87
84
- 

Return to bug 35581