From 69759e56382e56302cbbede289843733533b8eb2 Mon Sep 17 00:00:00 2001 From: Andrew Isherwood Date: Fri, 27 Aug 2021 11:53:00 +0100 Subject: [PATCH] Bug 28909: Allow illview to use backend template This commit allows illview to use an intranet template supplied by the backend, as per other stages. The template must be named illview.inc Test plan: - Apply the patch - Install FreeForm backend (https://github.com/PTFS-Europe/koha-ill-freeform) - Create a request - On the resulting "Manage ILL request" note the display is normal - Create a new file in the FreeForm backend directory: /intra-includes/illview.inc with the following content: [% BLOCK backend_jsinclude %] [% END %] - Restart Plack if enabled - Reload the page => TEST: Observe that the alert specified in the template is displayed --- Koha/Illrequest.pm | 17 +++++++++++++++++ ill/ill-requests.pl | 6 ++++++ .../prog/en/modules/ill/ill-requests.tt | 1 + t/db_dependent/Illrequests.t | 7 ++++++- 4 files changed, 30 insertions(+), 1 deletion(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 2eaa5accda..4324c709ca 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -710,6 +710,23 @@ sub mark_completed { }; } +=head2 backend_illview + +View and manage an ILL request + +=cut + +sub backend_illview { + my ( $self, $params ) = @_; + + my $response = $self->_backend_capability('illview',{ + request => $self, + other => $params, + }); + return $self->expandTemplate($response) if $response; + return $response; +} + =head2 backend_migrate Migrate a request from one backend to another. diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index fef5e550c7..aff5eff51b 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -97,6 +97,12 @@ if ( $backends_available ) { ( tran_success => $params->{tran_success} ) : () ), ); + my $backend_result = $request->backend_illview($params); + $template->param( + whole => $backend_result, + ) if $backend_result; + + } elsif ( $op eq 'create' ) { # We're in the process of creating a request my $request = Koha::Illrequest->new->load_backend( $params->{backend} ); 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 64336f5c4e..c2343844aa 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 @@ -484,6 +484,7 @@ [% ELSIF query_type == 'illview' %] + [% PROCESS $whole.template %] [% req_status = request.status %] [% IF error %] diff --git a/t/db_dependent/Illrequests.t b/t/db_dependent/Illrequests.t index 24ef726f96..4731e9ebde 100755 --- a/t/db_dependent/Illrequests.t +++ b/t/db_dependent/Illrequests.t @@ -517,7 +517,7 @@ subtest 'Backend testing (mocks)' => sub { subtest 'Backend core methods' => sub { - plan tests => 18; + plan tests => 19; $schema->storage->txn_begin; @@ -655,6 +655,11 @@ subtest 'Backend core methods' => sub { }, "Backend cancel: arbitrary stage."); + # backend_illview + $backend->set_series('illview', { stage => '', method => 'illview' }); + is_deeply($illrq->backend_illview({test => 1}), 0, + "Backend illview optional method."); + # backend_update_status $backend->set_series('update_status', { stage => 'bar', method => 'update_status' }); is_deeply($illrq->backend_update_status({test => 1}), -- 2.20.1