From cba57d8436d9499e6ee8ef6d03917527d5e5e67a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 9 Aug 2018 19:46:35 -0300 Subject: [PATCH] Bug 20443: (follow-up) Move GetBorrowerAttributes to Koha::Patron - ILSDI Either we display everything, or only the info from the attribute itself (i.e. not its type) Signed-off-by: Nick Clemens --- C4/ILSDI/Services.pm | 14 ++++++++++++-- t/db_dependent/ILSDI_Services.t | 10 ++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 29cb58a772..e929b37d91 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -506,8 +506,18 @@ sub GetPatronInfo { if ( $show_attributes && $show_attributes eq "1" ) { # FIXME Regression expected here, we do not retrieve the same field as previously # Waiting for answer on bug 14257 comment 15 - my $attrs = $patron->extended_attributes->search({ opac_display => 1 })->unblessed; - $borrower->{'attributes'} = $attrs; + $borrower->{'attributes'} = [ + map { + $_->type->opac_display + ? { + %{ $_->unblessed }, + %{ $_->type->unblessed }, + value => $_->attribute, # Backward compatibility + value_description => $_->description, # Awkward retro-compability... + } + : () + } $patron->extended_attributes->search + ]; } # Add is expired information diff --git a/t/db_dependent/ILSDI_Services.t b/t/db_dependent/ILSDI_Services.t index 0e1466f648..fdce3f4a0b 100644 --- a/t/db_dependent/ILSDI_Services.t +++ b/t/db_dependent/ILSDI_Services.t @@ -217,13 +217,11 @@ subtest 'GetPatronInfo/GetBorrowerAttributes test for extended patron attributes # Build a structure for comparison: my $cmp = { - 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'}, + borrowernumber => $brwr->{borrowernumber}, value => $attr_shown->{'attribute'}, - value_description => undef, + value_description => $attr_shown->{'attribute'}, + %$attr_type_visible, + %$attr_shown, }; is( $reply->{'charges'}, '10.00', -- 2.20.1