Bug 21199: Hide patron's attributes from ILSDI if required
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 9 Aug 2018 22:34:58 +0000 (19:34 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 30 Aug 2018 13:40:28 +0000 (13:40 +0000)
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
C4/ILSDI/Services.pm
t/db_dependent/ILSDI_Services.t

index 53292a5..a6f87a0 100644 (file)
@@ -475,7 +475,7 @@ sub GetPatronInfo {
     }
 
     if ( $cgi->param('show_attributes') eq "1" ) {
-        my $attrs = GetBorrowerAttributes( $borrowernumber, 0, 1 );
+        my $attrs = GetBorrowerAttributes( $borrowernumber, 1 );
         $borrower->{'attributes'} = $attrs;
     }
 
index 1eca594..9b6908f 100644 (file)
@@ -140,12 +140,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( {
@@ -165,12 +174,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',
         }
     } );
 
@@ -196,12 +213,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,
     };