Bug 10020: Remove code related to ethnicity
authorJonathan Druart <jonathan.druart@biblibre.com>
Fri, 10 Apr 2015 11:19:32 +0000 (13:19 +0200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 6 Oct 2015 13:30:32 +0000 (10:30 -0300)
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 <nick@quecheelibrary.org>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
C4/Members.pm
koha-tmpl/intranet-tmpl/prog/en/modules/members/members-update.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember-brief.tt
koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt
members/memberentry.pl
members/moremember.pl
opac/opac-user.pl
t/Borrower.t
t/db_dependent/Members.t

index 0b8e7d7..7ea9d9b 100644 (file)
@@ -135,8 +135,6 @@ BEGIN {
         &checkuserpassword
         &Check_Userid
         &Generate_Userid
-        &fixEthnicity
-        &ethnicitycategories
         &fixup_cardnumber
         &checkcardnumber
     );
@@ -1614,54 +1612,6 @@ sub GetBorrowercategoryList {
     return $data;
 }    # sub getborrowercategory
 
-=head2 ethnicitycategories
-
-  ($codes_arrayref, $labels_hashref) = &ethnicitycategories();
-
-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<ethnicity> 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);
index 3cabd4d..6337fc3 100644 (file)
@@ -49,8 +49,6 @@
 [% CASE 'contactfirstname'    %]<span>Contact: First name</span>
 [% CASE 'contacttitle'        %]<span>Contact: Title</span>
 [% CASE 'relationship'        %]<span>Contact: Relationship</span>
-[% CASE 'ethnicity'           %]<span>Ethnicity</span>
-[% CASE 'ethnotes'            %]<span>Ethnicity notes</span>
 [% CASE 'sex'                 %]<span>Sex</span>
 [% CASE 'altcontactfirstname' %]<span>Alternate contact: First name</span>
 [% CASE 'altcontactsurname'   %]<span>Alternate contact: Surname</span>
index b46424e..6196df0 100644 (file)
     <li><span class="label">Initials: </span>[% initials %]</li>
     <li><span class="label">Date of birth:</span>[% dateofbirth %]</li>
     <li><span class="label">Gender:</span>[% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]</li>[% END %]
-    [% IF ( printethnicityline ) %]
-    <li><span class="label">Ethnicity:</span>[% ethnicity %]</li>
-    <li><span class="label">Ethnicity notes: </span>[% ethnotes %]</li>
-    [% END %]
     [% IF ( isguarantee ) %]
         [% IF ( guaranteeloop ) %]
             <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
index 47ac879..5a8c5a9 100644 (file)
@@ -229,10 +229,6 @@ function validate1(date) {
     [% IF ( sex ) %]<li><span class="label">Gender:</span>
     [% IF ( sex == 'F' ) %]Female[% ELSIF ( sex == 'M' ) %]Male[% ELSE %][% sex %][% END %]
     </li>[% END %][% END %]
-    [% IF ( printethnicityline ) %]
-    <li><span class="label">Ethnicity:</span>[% ethnicity %]</li>
-    <li><span class="label">Ethnicity notes: </span>[% ethnotes %]</li>
-    [% END %]
     [% IF ( isguarantee ) %]
         [% IF ( guaranteeloop ) %]
             <li><span class="label">Guarantees:</span><ul>[% FOREACH guaranteeloo IN guaranteeloop %]<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% guaranteeloo.borrowernumber %]">[% guaranteeloo.name %]  </a></li>[% END %]</ul></li>
index 5841022..bc5efda 100755 (executable)
@@ -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,
index 6a5adcc..309efe6 100755 (executable)
@@ -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 );
index 052680b..0a02053 100755 (executable)
@@ -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;
 
index ce0c842..1e13725 100755 (executable)
@@ -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' );
index b2ebc9c..1858b7f 100755 (executable)
@@ -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")