Bugzilla – Attachment 101210 Details for
Bug 20443
Move C4::Members::Attributes to Koha namespace
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20443: Remove opac_display and opac_editable from Patron::Attribute
Bug-20443-Remove-opacdisplay-and-opaceditable-from.patch (text/plain), 5.84 KB, created by
Jonathan Druart
on 2020-03-20 15:04:58 UTC
(
hide
)
Description:
Bug 20443: Remove opac_display and opac_editable from Patron::Attribute
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 15:04:58 UTC
Size:
5.84 KB
patch
obsolete
>From 826c5e57386d4bdfff71a7c926a7a1488247528f Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 17 Jul 2018 11:13:09 -0300 >Subject: [PATCH] Bug 20443: Remove opac_display and opac_editable from > Patron::Attribute > >Same as previously for methods that have been added by bug 17792. >It's better to be explicite and tell we are fetch the related attribute's type > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Patron/Attribute.pm | 28 --------- > opac/opac-memberentry.pl | 8 +-- > t/db_dependent/Koha/Patron/Attributes.t | 78 ------------------------- > 3 files changed, 4 insertions(+), 110 deletions(-) > >diff --git a/Koha/Patron/Attribute.pm b/Koha/Patron/Attribute.pm >index 03bfd91550..0a44cbf49b 100644 >--- a/Koha/Patron/Attribute.pm >+++ b/Koha/Patron/Attribute.pm >@@ -52,34 +52,6 @@ sub store { > return $self->SUPER::store(); > } > >-=head3 opac_display >- >- my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... }); >- if ( $attribute->opac_display ) { ... } >- >-=cut >- >-sub opac_display { >- >- my $self = shift; >- >- return Koha::Patron::Attribute::Types->find( $self->code )->opac_display; >-} >- >-=head3 opac_editable >- >- my $attribute = Koha::Patron::Attribute->new({ code => 'a_code', ... }); >- if ( $attribute->is_opac_editable ) { ... } >- >-=cut >- >-sub opac_editable { >- >- my $self = shift; >- >- return Koha::Patron::Attribute::Types->find( $self->code )->opac_editable; >-} >- > =head3 type > > my $attribute_type = $attribute->type; >diff --git a/opac/opac-memberentry.pl b/opac/opac-memberentry.pl >index 391a78f8e0..e92af011a1 100755 >--- a/opac/opac-memberentry.pl >+++ b/opac/opac-memberentry.pl >@@ -518,7 +518,7 @@ sub DelEmptyFields { > sub FilterUnchangedAttributes { > my ( $borrowernumber, $entered_attributes ) = @_; > >- my @patron_attributes = grep {$_->opac_editable} Koha::Patron::Attributes->search({ borrowernumber => $borrowernumber })->as_list; >+ my @patron_attributes = grep {$_->type->opac_editable ? $_ : ()} Koha::Patron::Attributes->search({ borrowernumber => $borrowernumber })->as_list; > > my $patron_attribute_types; > foreach my $attr (@patron_attributes) { >@@ -581,7 +581,7 @@ sub GeneratePatronAttributesForm { > return []; > } > >- my @displayable_attributes = grep { $_->opac_display } >+ my @displayable_attributes = grep { $_->type->opac_display ? $_ : () } > Koha::Patron::Attributes->search({ borrowernumber => $borrowernumber })->as_list; > > my %attr_values = (); >@@ -594,14 +594,14 @@ sub GeneratePatronAttributesForm { > } > } > elsif ( defined $borrowernumber ) { >- my @editable_attributes = grep { $_->opac_editable } @displayable_attributes; >+ my @editable_attributes = grep { $_->type->opac_editable ? $_ : () } @displayable_attributes; > foreach my $attr (@editable_attributes) { > push @{ $attr_values{ $attr->code } }, $attr->attribute; > } > } > > # Add the non-editable attributes (that don't come from the form) >- foreach my $attr ( grep { !$_->opac_editable } @displayable_attributes ) { >+ foreach my $attr ( grep { !$_->type->opac_editable } @displayable_attributes ) { > push @{ $attr_values{ $attr->code } }, $attr->attribute; > } > >diff --git a/t/db_dependent/Koha/Patron/Attributes.t b/t/db_dependent/Koha/Patron/Attributes.t >index fbe1190e62..e403e0d30e 100644 >--- a/t/db_dependent/Koha/Patron/Attributes.t >+++ b/t/db_dependent/Koha/Patron/Attributes.t >@@ -157,84 +157,6 @@ subtest 'store() unique_id attributes tests' => sub { > $schema->storage->txn_rollback; > }; > >-subtest 'opac_display() tests' => sub { >- >- plan tests => 2; >- >- $schema->storage->txn_begin; >- >- my $patron >- = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >- my $attribute_type_1 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { opac_display => 1 } >- } >- ); >- >- my $attribute_1 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_1->{code}, >- attribute => $patron >- } >- ); >- is( $attribute_1->opac_display, 1, '->opac_display returns 1' ); >- >- my $attribute_type_2 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { opac_display => 0 } >- } >- ); >- >- my $attribute_2 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_2->{code}, >- attribute => $patron >- } >- ); >- is( $attribute_2->opac_display, 0, '->opac_display returns 0' ); >- >- $schema->storage->txn_rollback; >-}; >- >-subtest 'opac_editable() tests' => sub { >- >- plan tests => 2; >- >- $schema->storage->txn_begin; >- >- my $patron >- = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >- my $attribute_type_1 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { opac_editable => 1 } >- } >- ); >- >- my $attribute_1 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_1->{code}, >- attribute => $patron >- } >- ); >- is( $attribute_1->opac_editable, 1, '->opac_editable returns 1' ); >- >- my $attribute_type_2 = $builder->build( >- { source => 'BorrowerAttributeType', >- value => { opac_editable => 0 } >- } >- ); >- >- my $attribute_2 = Koha::Patron::Attribute->new( >- { borrowernumber => $patron, >- code => $attribute_type_2->{code}, >- attribute => $patron >- } >- ); >- is( $attribute_2->opac_editable, 0, '->opac_editable returns 0' ); >- >- $schema->storage->txn_rollback; >-}; >- > subtest 'type() tests' => sub { > > plan tests => 4; >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 20443
:
101122
|
101123
|
101124
|
101125
|
101126
|
101127
|
101128
|
101129
|
101130
|
101131
|
101132
|
101133
|
101134
|
101135
|
101136
|
101137
|
101138
|
101139
|
101140
|
101141
|
101142
|
101143
|
101144
|
101145
|
101146
|
101147
|
101148
|
101149
|
101150
|
101209
| 101210 |
101211
|
101212
|
101213
|
101214
|
101215
|
101216
|
101217
|
101218
|
101219
|
101220
|
101221
|
101222
|
101223
|
101224
|
101225
|
101226
|
101227
|
101228
|
101229
|
101230
|
101231
|
101232
|
101233
|
101234
|
101235
|
101236
|
101237
|
101472
|
104519