From fb59c5c7c440da6bb2a721efde6597847ebd8e6b Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Apr 2015 13:19:32 +0200 Subject: [PATCH] Bug 10020: Remove code related to ethnicity This is a(nother) vestige of Koha (2.2?). This patch removes unused code related to the 'ethnicity'. In detail: There is no way to fill the ethnicity table. There is no way to fill the borrowers.ethnicity and borrowers.ethnotes. BUT if borrowers.ethnicity exists, the value is displayed on members/moremember.pl (and only here). Test plan: Apply this patch and confirm there is no regression on adding/updating/deleting patrons. Note that you don't see the ethnicity value on the moremember.pl page even if a patron has it. Signed-off-by: Nick Clemens Signed-off-by: Kyle M Hall Signed-off-by: Tomas Cohen Arazi --- C4/Members.pm | 50 ------------------- .../prog/en/modules/members/members-update.tt | 2 - .../en/modules/members/moremember-brief.tt | 4 -- .../prog/en/modules/members/moremember.tt | 4 -- members/memberentry.pl | 17 +------ members/moremember.pl | 5 -- opac/opac-user.pl | 2 - t/Borrower.t | 12 +---- t/db_dependent/Members.t | 3 -- 9 files changed, 3 insertions(+), 96 deletions(-) diff --git a/C4/Members.pm b/C4/Members.pm index 0b8e7d7c29..7ea9d9b6fd 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -135,8 +135,6 @@ BEGIN { &checkuserpassword &Check_Userid &Generate_Userid - &fixEthnicity - ðnicitycategories &fixup_cardnumber &checkcardnumber ); @@ -1614,54 +1612,6 @@ sub GetBorrowercategoryList { return $data; } # sub getborrowercategory -=head2 ethnicitycategories - - ($codes_arrayref, $labels_hashref) = ðnicitycategories(); - -Looks up the different ethnic types in the database. Returns two -elements: a reference-to-array, which lists the ethnicity codes, and a -reference-to-hash, which maps the ethnicity codes to ethnicity -descriptions. - -=cut - -#' - -sub ethnicitycategories { - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("Select code,name from ethnicity order by name"); - $sth->execute; - my %labels; - my @codes; - while ( my $data = $sth->fetchrow_hashref ) { - push @codes, $data->{'code'}; - $labels{ $data->{'code'} } = $data->{'name'}; - } - return ( \@codes, \%labels ); -} - -=head2 fixEthnicity - - $ethn_name = &fixEthnicity($ethn_code); - -Takes an ethnicity code (e.g., "european" or "pi") and returns the -corresponding descriptive name from the C table in the -Koha database ("European" or "Pacific Islander"). - -=cut - -#' - -sub fixEthnicity { - my $ethnicity = shift; - return unless $ethnicity; - my $dbh = C4::Context->dbh; - my $sth = $dbh->prepare("Select name from ethnicity where code = ?"); - $sth->execute($ethnicity); - my $data = $sth->fetchrow_hashref; - return $data->{'name'}; -} # sub fixEthnicity - =head2 GetAge $dateofbirth,$date = &GetAge($date); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt index 3cabd4dd12..6337fc39b2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt @@ -49,8 +49,6 @@ [% CASE 'contactfirstname' %]Contact: First name [% CASE 'contacttitle' %]Contact: Title [% CASE 'relationship' %]Contact: Relationship -[% CASE 'ethnicity' %]Ethnicity -[% CASE 'ethnotes' %]Ethnicity notes [% CASE 'sex' %]Sex [% CASE 'altcontactfirstname' %]Alternate contact: First name [% CASE 'altcontactsurname' %]Alternate contact: Surname diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt index b46424e71a..6196df037f 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt @@ -49,10 +49,6 @@
  • Initials: [% initials %]
  • Date of birth:[% dateofbirth %]
  • Gender:[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
  • [% END %] - [% IF ( printethnicityline ) %] -
  • Ethnicity:[% ethnicity %]
  • -
  • Ethnicity notes: [% ethnotes %]
  • - [% END %] [% IF ( isguarantee ) %] [% IF ( guaranteeloop ) %]
  • Guarantees:
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt index 47ac879769..5a8c5a91d5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -229,10 +229,6 @@ function validate1(date) { [% IF ( sex ) %]
  • Gender: [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
  • [% END %][% END %] - [% IF ( printethnicityline ) %] -
  • Ethnicity:[% ethnicity %]
  • -
  • Ethnicity notes: [% ethnotes %]
  • - [% END %] [% IF ( isguarantee ) %] [% IF ( guaranteeloop ) %]
  • Guarantees:
  • diff --git a/members/memberentry.pl b/members/memberentry.pl index 5841022b3c..bc5efda4e0 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -90,7 +90,6 @@ my $guarantorinfo = $input->param('guarantorinfo'); my $step = $input->param('step') || 0; my @errors; my $default_city; -# NOTE: Alert for ethnicity and ethnotes fields, they are invalid in all borrowers form my $borrower_data; my $NoUpdateLogin; my $userenv = C4::Context->userenv; @@ -507,26 +506,13 @@ if(!defined($data{'sex'})){ } ##Now all the data to modify a member. -my ($categories,$labels)=ethnicitycategories(); - -my $ethnicitycategoriescount=$#{$categories}; -my $ethcatpopup; -if ($ethnicitycategoriescount>=0) { - $ethcatpopup = CGI::popup_menu(-name=>'ethnicity', - -id => 'ethnicity', - -tabindex=>'', - -values=>$categories, - -default=>$data{'ethnicity'}, - -labels=>$labels); - $template->param(ethcatpopup => $ethcatpopup); # bad style, has to be fixed -} my @typeloop; my $no_categories = 1; my $no_add; foreach (qw(C A S P I X)) { my $action="WHERE category_type=?"; - ($categories,$labels)=GetborCatFromCatType($_,$action); + my ($categories,$labels)=GetborCatFromCatType($_,$action); if(scalar(@$categories) > 0){ $no_categories = 0; } my @categoryloop; foreach my $cat (@$categories){ @@ -709,7 +695,6 @@ $template->param( nodouble => $nodouble, borrowernumber => $borrowernumber, #register number guarantorid => ($borrower_data->{'guarantorid'} || $guarantorid), - ethcatpopup => $ethcatpopup, relshiploop => \@relshipdata, city_loop => $city_arrayref, borrotitlepopup => $borrotitlepopup, diff --git a/members/moremember.pl b/members/moremember.pl index 6a5adcccd6..309efe655b 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -155,7 +155,6 @@ if ( IsDebarred($borrowernumber) ) { } } -$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} ); $data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex}; my $catcode; @@ -167,10 +166,6 @@ if ( $category_type eq 'C') { $template->param( 'catcode' => $catcodes->[0]) if $cnt == 1; } - -if ( $data->{'ethnicity'} || $data->{'ethnotes'} ) { - $template->param( printethnicityline => 1 ); -} my ( $count, $guarantees ) = GetGuarantees( $data->{'borrowernumber'} ); if ( $count ) { $template->param( isguarantee => 1 ); diff --git a/opac/opac-user.pl b/opac/opac-user.pl index 052680b604..0a020532d3 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -82,8 +82,6 @@ my ( $borr ) = GetMemberDetails( $borrowernumber ); my ( $today_year, $today_month, $today_day) = Today(); my ($warning_year, $warning_month, $warning_day) = split /-/, $borr->{'dateexpiry'}; -$borr->{'ethnicity'} = fixEthnicity( $borr->{'ethnicity'} ); - my $debar = IsDebarred($borrowernumber); my $userdebarred; diff --git a/t/Borrower.t b/t/Borrower.t index ce0c8424b2..1e13725802 100755 --- a/t/Borrower.t +++ b/t/Borrower.t @@ -106,8 +106,6 @@ my $borrower = Koha::Borrower->new( guarantorid => '123454321', borrowernotes => 'borrowernotes', relationship => 'myRelationship', - ethnicity => undef, - ethnotes => undef, sex => 'M', password => 'hfkurhfe976634èj!', flags => '55555', @@ -132,7 +130,7 @@ my $borrower = Koha::Borrower->new( #borrower Accessor tests subtest 'Accessor tests' => sub { - plan tests => 67; + plan tests => 65; is( $borrower->borrowernumber, '12345', 'borrowernumber accessor returns correct value' ); is( $borrower->cardnumber, '1234567890', 'cardnumber accessor returns correct value' ); is( $borrower->surname, 'mySurname', 'surname accessor returns correct value' ); @@ -179,8 +177,6 @@ subtest 'Accessor tests' => sub { is( $borrower->guarantorid, '123454321', 'guarantorid accessor returns correct value' ); is( $borrower->borrowernotes, 'borrowernotes', 'borrowernotes accessor returns correct value' ); is( $borrower->relationship, 'myRelationship', 'relationship accessor returns correct value' ); - is( $borrower->ethnicity, undef, 'ethnicity accessor returns correct value' ); - is( $borrower->ethnotes, undef, 'ethnotes accessor returns correct value' ); is( $borrower->sex, 'M', 'sex accessor returns correct value' ); is( $borrower->password, 'hfkurhfe976634èj!', 'password accessor returns correct value' ); is( $borrower->flags, '55555', 'flags accessor returns correct value' ); @@ -204,7 +200,7 @@ subtest 'Accessor tests' => sub { #borrower Set tests subtest 'Set tests' => sub { - plan tests => 67; + plan tests => 65; $borrower->set( { @@ -254,8 +250,6 @@ subtest 'Set tests' => sub { guarantorid => '223454321', borrowernotes => 'Sborrowernotes', relationship => 'SmyRelationship', - ethnicity => undef, - ethnotes => undef, sex => 'F', password => 'zerzerzer#', flags => '666666', @@ -324,8 +318,6 @@ subtest 'Set tests' => sub { is( $borrower->guarantorid, '223454321', 'guarantorid field set ok' ); is( $borrower->borrowernotes, 'Sborrowernotes', 'borrowernotes field set ok' ); is( $borrower->relationship, 'SmyRelationship', 'relationship field set ok' ); - is( $borrower->ethnicity, undef, 'ethnicity field set ok' ); - is( $borrower->ethnotes, undef, 'ethnotes field set ok' ); is( $borrower->sex, 'F', 'sex field set ok' ); is( $borrower->password, 'zerzerzer#', 'password field set ok' ); is( $borrower->flags, '666666', 'flags field set ok' ); diff --git a/t/db_dependent/Members.t b/t/db_dependent/Members.t index b2ebc9c152..1858b7f2c3 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -41,7 +41,6 @@ my $BRANCHCODE = 'CPL'; my $CHANGED_FIRSTNAME = "Marry Ann"; my $EMAIL = "Marie\@email.com"; my $EMAILPRO = "Marie\@work.com"; -my $ETHNICITY = "German"; my $PHONE = "555-12123"; # XXX should be randomised and checked against the database @@ -113,14 +112,12 @@ is($member->{dateofbirth}, undef, "Empty dates handled correctly"); $member->{firstname} = $CHANGED_FIRSTNAME; $member->{email} = $EMAIL; -$member->{ethnicity} = $ETHNICITY; $member->{phone} = $PHONE; $member->{emailpro} = $EMAILPRO; ModMember(%$member); my $changedmember=GetMemberDetails("",$CARDNUMBER); ok ( $changedmember->{firstname} eq $CHANGED_FIRSTNAME && $changedmember->{email} eq $EMAIL && - $changedmember->{ethnicity} eq $ETHNICITY && $changedmember->{phone} eq $PHONE && $changedmember->{emailpro} eq $EMAILPRO , "Member Changed") -- 2.39.5