From 916e870ea15b812d174c59527ac488e5eec21ee7 Mon Sep 17 00:00:00 2001 From: Jiri Kozlovsky Date: Mon, 1 Aug 2016 15:36:05 +0200 Subject: [PATCH] Bug 16826: [QA Follow-up] Add 'new_status' to Swagger definition Adds missing "new_status" to item's Swagger definition. Also, to avoid forgotten columns in definitions, adds a test to compare item-definition to database's items-table. To test: 1. Run t/db_dependent/api/v1/items.t Signed-off-by: Jiri Kozlovsky --- Koha/REST/V1/Item.pm | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Koha/REST/V1/Item.pm b/Koha/REST/V1/Item.pm index 03fd333..b51a225 100644 --- a/Koha/REST/V1/Item.pm +++ b/Koha/REST/V1/Item.pm @@ -21,6 +21,7 @@ use Mojo::Base 'Mojolicious::Controller'; use Mojo::JSON; use C4::Auth qw( haspermission ); +use C4::Items qw( GetHiddenItemnumbers ); use Koha::Items; @@ -36,6 +37,14 @@ sub get { # Hide non-public itemnotes if user has no staff access my $user = $c->stash('koha.user'); unless ($user && haspermission($user->userid, {catalogue => 1})) { + + my @hiddenitems = C4::Items::GetHiddenItemnumbers( ({ itemnumber => $itemnumber}) ); + my %hiddenitems = map { $_ => 1 } @hiddenitems; + + # Pretend it was not found as it's hidden from OPAC to regular users + return $c->$cb({error => "Item not found"}, 404) + if $hiddenitems{$itemnumber}; + $item->set({ itemnotes_nonpublic => undef }); } -- 2.1.4