From 2ba7dac24bb8115aa93b7547f9a3165586974592 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Wed, 30 Jul 2014 16:28:14 +0200 Subject: [PATCH] Bug 7290: QA fixes 1) Use the new isSuperlibrarian instead of $userflags->{superlibrarian} 2) Update the database update comment 3) Fix capitalization of "Duplicate Barcode" 4) Add comments in t/Acquisition/CanUserReceiveBasket.t --- C4/Acquisition.pm | 2 +- installer/data/mysql/updatedatabase.pl | 2 +- koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt | 2 +- t/Acquisition/CanUserReceiveBasket.t | 8 ++++++++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git C4/Acquisition.pm C4/Acquisition.pm index 505aaf1..902a7fa 100644 --- C4/Acquisition.pm +++ C4/Acquisition.pm @@ -867,7 +867,7 @@ sub CanUserReceiveOrder { my $branch = C4::Context->userenv->{'branch'}; - unless ($userflags->{superlibrarian} + unless (C4::Context->IsSuperLibrarian() || (!ref $userflags->{acquisition} && $userflags->{acquisition}) || (ref $userflags->{acquisition} && $userflags->{acquisition}->{order_receive_all}) ) { diff --git installer/data/mysql/updatedatabase.pl installer/data/mysql/updatedatabase.pl index 5bb5bd2..b2d3684 100755 --- installer/data/mysql/updatedatabase.pl +++ installer/data/mysql/updatedatabase.pl @@ -8609,7 +8609,7 @@ if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { INSERT INTO permissions (module_bit, code, description) VALUES (11, 'order_receive_all', 'Receive all orders') "); - print "Upgrade to $DBversion done (Add aqorders.branch and permission order_receive_all)\n"; + print "Upgrade to $DBversion done (Bug 7290: Add permission order_receive_all)\n"; SetVersion($DBversion); } diff --git koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt index 9f0065f..f303c44 100644 --- koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt +++ koha-tmpl/intranet-tmpl/prog/en/modules/acqui/parcel.tt @@ -170,7 +170,7 @@
  • [% error.error_param %] [% IF ( error.error_duplicate_barcode ) %] - Duplicate Barcode + Duplicate barcode [% ELSIF (error.error_cannot_receive_order) %] You were not authorised to receive this order [% END %] diff --git t/Acquisition/CanUserReceiveBasket.t t/Acquisition/CanUserReceiveBasket.t index f0a7453..b0eb385 100644 --- t/Acquisition/CanUserReceiveBasket.t +++ t/Acquisition/CanUserReceiveBasket.t @@ -37,28 +37,36 @@ my $order3 = { $userenv->{branch} = 'B1'; +# User can receive any orders thanks to his permissions ok( CanUserReceiveOrder($borrower, $order1, {superlibrarian => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive_all => 1 }}) ); +# User cannot receive any order because of his lack of permission ok( not CanUserReceiveOrder($borrower, $order1, {}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => 0}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 0 }}) ); +# User with order_receive permission can receive only orders of his branch (B1) +# and orders that don't belong to any branch ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) ); ok( CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) ); ok( not CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) ); $userenv->{branch} = 'B2'; +# User can receive any order thanks to his permissions ok( CanUserReceiveOrder($borrower, $order1, {superlibrarian => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => 1}) ); ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive_all => 1 }}) ); +# User cannot receive any order because of his lack of permission ok( not CanUserReceiveOrder($borrower, $order1, {}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => 0}) ); ok( not CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 0 }}) ); +# User with order_receive permission can receive only orders of his branch (B2) +# and orders that don't belong to any branch ok( CanUserReceiveOrder($borrower, $order1, {acquisition => { order_receive => 1 }}) ); ok( not CanUserReceiveOrder($borrower, $order2, {acquisition => { order_receive => 1 }}) ); ok( CanUserReceiveOrder($borrower, $order3, {acquisition => { order_receive => 1 }}) ); -- 1.9.1