Bugzilla – Attachment 101133 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 num_patron
Bug-20443-Remove-numpatron.patch (text/plain), 6.82 KB, created by
Jonathan Druart
on 2020-03-20 14:47:38 UTC
(
hide
)
Description:
Bug 20443: Remove num_patron
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-20 14:47:38 UTC
Size:
6.82 KB
patch
obsolete
>From bb705904b5a1fda9508665228fb2dab19ac815ae Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 16 Jul 2018 19:37:30 -0300 >Subject: [PATCH] Bug 20443: Remove num_patron > >Replace C4::Members::AttributeTypes->num_patron with >Koha::Patrons->filter_by_attribute_type > >Signed-off-by: Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/Patrons.pm | 15 ++++++ > admin/patron-attr-types.pl | 94 +++++++++++++++++++++----------------- > 2 files changed, 68 insertions(+), 41 deletions(-) > >diff --git a/Koha/Patrons.pm b/Koha/Patrons.pm >index 2a2894500f..ce732e00d4 100644 >--- a/Koha/Patrons.pm >+++ b/Koha/Patrons.pm >@@ -427,6 +427,21 @@ sub update_category_to { > return $counter; > } > >+=head3 filter_by_attribute_type >+ >+my $patrons = Koha::Patrons->filter_by_attribute_type($attribute_type_code); >+ >+Return a Koha::Patrons set with patrons having the attribute defined. >+ >+=cut >+ >+sub filter_by_attribute_type { >+ my ( $self, $attribute_type ) = @_; >+ my $rs = Koha::Patron::Attributes->search( { code => $attribute_type } ) >+ ->_resultset()->search_related('borrowernumber'); >+ return Koha::Patrons->_new_from_dbic($rs); >+} >+ > =head3 _type > > =cut >diff --git a/admin/patron-attr-types.pl b/admin/patron-attr-types.pl >index fd87e73c4d..ab0ebccf66 100755 >--- a/admin/patron-attr-types.pl >+++ b/admin/patron-attr-types.pl >@@ -28,7 +28,6 @@ use C4::Auth; > use C4::Context; > use C4::Output; > use C4::Koha; >-use C4::Members::AttributeTypes; > use Koha::Patron::Attribute::Types; > > use Koha::AuthorisedValues; >@@ -111,53 +110,64 @@ sub error_add_attribute_type_form { > } > > sub add_update_attribute_type { >- my $op = shift; >+ my $op = shift; > my $template = shift; >- my $code = shift; >- >- my $description = $input->param('description'); >+ my $code = shift; >+ >+ my $description = $input->param('description'); >+ my $repeatable = $input->param('repeatable') || 0; >+ my $unique_id = $input->param('unique_id') || 0; >+ my $opac_display = $input->param('opac_display') || 0; >+ my $opac_editable = $input->param('opac_editable') || 0; >+ my $staff_searchable = $input->param('staff_searchable') || 0; >+ my $authorised_value_category = $input->param('authorised_value_category'); >+ my $display_checkout = $input->param('display_checkout') || 0; >+ my $category_code = $input->param('category_code'); >+ my $class = $input->param('class'); > >- my $attr_type; >- if ($op eq 'edit') { >- $attr_type = C4::Members::AttributeTypes->fetch($code); >+ my $attr_type = Koha::Patron::Attribute::Types->find($code); >+ if ( $op eq 'edit' ) { > $attr_type->description($description); >- } else { >- my $existing = C4::Members::AttributeTypes->fetch($code); >- if (defined($existing)) { >- $template->param(duplicate_code_error => $code); >+ } >+ else { >+ if ($attr_type) { # Already exists >+ $template->param( duplicate_code_error => $code ); >+ > # FIXME Regression here > # Form will not be refilled with entered values on error > error_add_attribute_type_form($template); > return 0; > } >- $attr_type = C4::Members::AttributeTypes->new($code, $description); >- my $repeatable = $input->param('repeatable'); >- $attr_type->repeatable($repeatable); >- my $unique_id = $input->param('unique_id'); >- $attr_type->unique_id($unique_id); >+ $attr_type = Koha::Patron::Attribute::Type->new( >+ { >+ code => $code, >+ description => $description, >+ repeatable => $repeatable, >+ unique_id => $unique_id, >+ } >+ ); > } >+ $attr_type->set( >+ { >+ opac_display => $opac_display, >+ opac_editable => $opac_editable, >+ staff_searchable => $staff_searchable, >+ authorised_value_category => $authorised_value_category, >+ display_checkout => $display_checkout, >+ category_code => $category_code, >+ class => $class, >+ } >+ )->store; > >- my $opac_display = $input->param('opac_display'); >- $attr_type->opac_display($opac_display); >- my $opac_editable = $input->param('opac_editable'); >- $attr_type->opac_editable($opac_editable); >- my $staff_searchable = $input->param('staff_searchable'); >- $attr_type->staff_searchable($staff_searchable); >- my $authorised_value_category = $input->param('authorised_value_category'); >- $attr_type->authorised_value_category($authorised_value_category); >- my $display_checkout = $input->param('display_checkout'); >- $attr_type->display_checkout($display_checkout); >- $attr_type->category_code(scalar $input->param('category_code')); >- $attr_type->class(scalar $input->param('class')); >- my @branches = $input->multi_param('branches'); >- $attr_type->branches( \@branches ); >- >- if ($op eq 'edit') { >- $template->param(edited_attribute_type => $attr_type->code()); >- } else { >- $template->param(added_attribute_type => $attr_type->code()); >+ my @branches = grep { ! /^\s*$/ } $input->multi_param('branches'); >+ $attr_type->library_limits( \@branches ); >+ >+ if ( $op eq 'edit' ) { >+ $template->param( edited_attribute_type => $attr_type->code() ); >+ } >+ else { >+ $template->param( added_attribute_type => $attr_type->code() ); > } >- $attr_type->store(); > > return 1; > } >@@ -166,7 +176,7 @@ sub delete_attribute_type_form { > my $template = shift; > my $code = shift; > >- my $attr_type = C4::Members::AttributeTypes->fetch($code); >+ my $attr_type = Koha::Patron::Attribute::Types->find($code); > my $display_list = 0; > if (defined($attr_type)) { > $template->param( >@@ -186,16 +196,18 @@ sub delete_attribute_type { > my $template = shift; > my $code = shift; > >- my $attr_type = C4::Members::AttributeTypes->fetch($code); >+ my $attr_type = Koha::Patron::Attribute::Types->find($code); > if (defined($attr_type)) { >- if ($attr_type->num_patrons() > 0) { >+ # TODO Check must be done for previous step as well >+ if ( my $num_patrons = Koha::Patrons->filter_by_attribute_type($code)->count ) { > $template->param(ERROR_delete_in_use => $code); >- $template->param(ERROR_num_patrons => $attr_type->num_patrons()); >+ $template->param(ERROR_num_patrons => $num_patrons ); > } else { > $attr_type->delete(); > $template->param(deleted_attribute_type => $code); > } > } else { >+ # FIXME Really needed? > $template->param(ERROR_delete_not_found => $code); > } > } >-- >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