From c8a1422d41b71669c2f761174974b6839a797b83 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Aug 2018 19:34:58 -0300 Subject: [PATCH] Bug 21199: Hide patron's attributes from ILSDI if required Signed-off-by: Katrin Fischer Signed-off-by: Martin Renvoize (cherry picked from commit dabd86cf6eab70751cc1a476b47cdf9f1648788f) Signed-off-by: Fridolin Somers (cherry picked from commit 0d588160cf38e0ca5b79955376f18710d0a0ca3e) Signed-off-by: Fridolin Somers --- C4/ILSDI/Services.pm | 2 +- t/db_dependent/ILSDI_Services.t | 35 ++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 287ac0287b..58c6e92bd9 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -444,7 +444,7 @@ sub GetPatronInfo { } if ( $cgi->param('show_attributes') eq "1" ) { - my $attrs = GetBorrowerAttributes( $borrowernumber, 0, 1 ); + my $attrs = GetBorrowerAttributes( $borrowernumber, 1 ); $borrower->{'attributes'} = $attrs; } diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index 7677db0f04..4e84ee077b 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -132,12 +132,21 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes my $attr_type = $builder->build( { source => 'BorrowerAttributeType', value => { - code => 'DOORCODE', + code => 'HIDEME', opac_display => 0, authorised_value_category => '', class => '', } } ); + my $attr_type_visible = $builder->build( { + source => 'BorrowerAttributeType', + value => { + code => 'SHOWME', + opac_display => 1, + authorised_value_category => '', + class => '', + } + } ); # Create a new user: my $brwr = $builder->build( { @@ -157,12 +166,20 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes } ); # Set the new attribute for our user: - my $attr = $builder->build( { + my $attr_hidden = $builder->build( { source => 'BorrowerAttribute', value => { borrowernumber => $brwr->{'borrowernumber'}, code => $attr_type->{'code'}, - attribute => '1337', + attribute => '1337 hidden', + } + } ); + my $attr_shown = $builder->build( { + source => 'BorrowerAttribute', + value => { + borrowernumber => $brwr->{'borrowernumber'}, + code => $attr_type_visible->{'code'}, + attribute => '1337 shown', } } ); @@ -179,12 +196,12 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes # Build a structure for comparison: my $cmp = { - category_code => $attr_type->{'category_code'}, - class => $attr_type->{'class'}, - code => $attr->{'code'}, - description => $attr_type->{'description'}, - display_checkout => $attr_type->{'display_checkout'}, - value => $attr->{'attribute'}, + category_code => $attr_type_visible->{'category_code'}, + class => $attr_type_visible->{'class'}, + code => $attr_shown->{'code'}, + description => $attr_type_visible->{'description'}, + display_checkout => $attr_type_visible->{'display_checkout'}, + value => $attr_shown->{'attribute'}, value_description => undef, }; -- 2.39.5