From 498bdd2671f6819154db9ca685733deca9e602e2 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 10 Apr 2015 13:19:32 +0200 Subject: [PATCH] [SIGNED OFF] 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 --- C4/Members.pm | 50 ---------------------- .../prog/en/modules/members/members-update.tt | 2 - .../prog/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 4ca83b9..825f198 100644 --- a/C4/Members.pm +++ b/C4/Members.pm @@ -136,8 +136,6 @@ BEGIN { &checkuserpassword &Check_Userid &Generate_Userid - &fixEthnicity - ðnicitycategories &fixup_cardnumber &checkcardnumber ); @@ -1724,54 +1722,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 2a094dd..f6fc75d 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 b46424e..6196df0 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 d01573b..5c42c9d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt @@ -218,10 +218,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 4638508..d0d9001 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -92,7 +92,6 @@ my @errors; my $default_city; # $check_categorytype contains the value of duplicate borrowers category type to redirect in good template in step =2 my $check_categorytype=$input->param('check_categorytype'); -# NOTE: Alert for ethnicity and ethnotes fields, they are invalid in all borrowers form my $borrower_data; my $NoUpdateLogin; my $userenv = C4::Context->userenv; @@ -509,26 +508,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){ @@ -711,7 +697,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 7dc7ef3..13bdefc 100755 --- a/members/moremember.pl +++ b/members/moremember.pl @@ -153,7 +153,6 @@ if ( IsDebarred($borrowernumber) ) { } } -$data->{'ethnicity'} = fixEthnicity( $data->{'ethnicity'} ); $data->{ "sex_".$data->{'sex'}."_p" } = 1 if defined $data->{sex}; my $catcode; @@ -165,10 +164,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 56354c8..397521e 100755 --- a/opac/opac-user.pl +++ b/opac/opac-user.pl @@ -83,8 +83,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 ce0c842..1e13725 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 dc2b0a3..90d30ff 100755 --- a/t/db_dependent/Members.t +++ b/t/db_dependent/Members.t @@ -43,7 +43,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 @@ -117,14 +116,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") -- 1.9.1