@@ -, +, @@ - Apply the patch and make sure the atomic database update is run - Make sure you have a few ILL requests, with at least two different statuses - Check that all requests are still displayed in the main table of ILL requests - Add one of the statuses* you have in your database to the ILLHiddenRequestStatuses syspref, reload the ILL module frontpage and verify that requests with the given status are not displayed - Change the syspref to another status and verify requests with that status are now hidden - Change the syspref to hold both statuses, separated by the pipe symbol (e.g.: A|B). Verify that no requests with the given statuses are now displayed - Run the ILL REST API tests, e.g.: $ sudo koha-shell -c "prove t/db_dependent/api/v1/illrequests.t" kohadev --- Koha/REST/V1/Illrequests.pm | 9 ++++++++ .../bug23391-hide-finished-ill-requests.perl | 10 ++++++++ installer/data/mysql/sysprefs.sql | 1 + .../admin/preferences/circulation.pref | 5 ++++ t/db_dependent/api/v1/illrequests.t | 23 ++++++++++++++++--- 5 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug23391-hide-finished-ill-requests.perl --- a/Koha/REST/V1/Illrequests.pm +++ a/Koha/REST/V1/Illrequests.pm @@ -19,6 +19,7 @@ use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; +use C4::Context; use Koha::Illrequests; use Koha::Illrequestattributes; use Koha::Libraries; @@ -54,9 +55,17 @@ sub list { delete $args->{embed}; } + # Get the pipe-separated string of hidden ILL statuses + my $hidden_statuses_string = C4::Context->preference('ILLHiddenRequestStatuses'); + # Turn into arrayref + my $hidden_statuses = [ split /\|/, $hidden_statuses_string ]; + # Get all requests # If necessary, only get those from a specified patron my @requests = Koha::Illrequests->search({ + $hidden_statuses + ? ( status => { 'not in' => $hidden_statuses } ) + : (), $args->{borrowernumber} ? ( borrowernumber => $args->{borrowernumber} ) : () --- a/installer/data/mysql/atomicupdate/bug23391-hide-finished-ill-requests.perl +++ a/installer/data/mysql/atomicupdate/bug23391-hide-finished-ill-requests.perl @@ -0,0 +1,10 @@ +$DBversion = 'XXX'; +if( CheckVersion( $DBversion ) ) { + $dbh->do( q{ + INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) + VALUES ('ILLHiddenRequestStatuses',NULL,NULL,'ILL statuses that are considered finished and should not be displayed in the ILL module','multiple') + }); + + SetVersion( $DBversion ); + print "Upgrade to $DBversion done (Bug 23391 - Hide finished ILL requests)\n"; +} --- a/installer/data/mysql/sysprefs.sql +++ a/installer/data/mysql/sysprefs.sql @@ -228,6 +228,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('IDreamBooksResults','0','','Display IDreamBooks.com rating in search results','YesNo'), ('IDreamBooksReviews','0','','Display book review snippets from IDreamBooks.com','YesNo'), ('IdRef','0','','Disable/enable the IdRef webservice from the OPAC detail page.','YesNo'), +('ILLHiddenRequestStatuses', NULL, NULL, 'ILL statuses that are considered finished and should not be displayed in the ILL module', 'multiple'), ('IllLog', 0, '', 'If ON, log information about ILL requests', 'YesNo'), ('ILLModule','0','If ON, enables the interlibrary loans module.','','YesNo'), ('ILLModuleCopyrightClearance','','70|10','Enter text to enable the copyright clearance stage of request creation. Text will be displayed','Textarea'), --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -832,6 +832,11 @@ Circulation: yes: Enable no: Disable - unmediated Interlibrary loan requests. If enabled and the ILL backend supports it, the newly created requests are immediately requested by backend. + - + - "ILL statuses that are considered finished and should not be displayed in the ILL module: " + - pref: ILLHiddenRequestStatuses + class: multi + - (separated with |). If left empty, all ILL requests will be displayed. Fines Policy: - - Calculate fines based on days overdue --- a/t/db_dependent/api/v1/illrequests.t +++ a/t/db_dependent/api/v1/illrequests.t @@ -40,7 +40,7 @@ my $t = Test::Mojo->new('Koha::REST::V1'); subtest 'list() tests' => sub { - plan tests => 24; + plan tests => 30; # Mock ILLBackend (as object) my $backend = Test::MockObject->new; @@ -91,7 +91,8 @@ subtest 'list() tests' => sub { value => { backend => 'Mock', branchcode => $library->branchcode, - borrowernumber => $patron_1->borrowernumber + borrowernumber => $patron_1->borrowernumber, + status => 'STATUS1', } } ); @@ -129,7 +130,8 @@ subtest 'list() tests' => sub { value => { backend => 'Mock', branchcode => $library->branchcode, - borrowernumber => $patron_2->borrowernumber + borrowernumber => $patron_2->borrowernumber, + status => 'STATUS2', } } ); @@ -162,6 +164,21 @@ subtest 'list() tests' => sub { $tx->req->env( { REMOTE_ADDR => $remote_address } ); $t->request_ok($tx)->status_is(200)->json_is( [ $response2 ] ); + # Test the ILLHiddenRequestStatuses syspref + t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'STATUS1' ); + $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' ); + $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); + $tx->req->env( { REMOTE_ADDR => $remote_address } ); + $t->request_ok($tx)->status_is(200) + ->json_is( [ $req2_formatted ] ); + + t::lib::Mocks::mock_preference( 'ILLHiddenRequestStatuses', 'STATUS2' ); + $tx = $t->ua->build_tx( GET => '/api/v1/illrequests' ); + $tx->req->cookies( { name => 'CGISESSID', value => $session_id } ); + $tx->req->env( { REMOTE_ADDR => $remote_address } ); + $t->request_ok($tx)->status_is(200) + ->json_is( [ $req_formatted ] ); + $schema->storage->txn_rollback; }; --