Bugzilla – Attachment 125499 Details for
Bug 28633
Add a preferred name field to patrons
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28633: Add preferred name field to patrons
Bug-28633-Add-preferred-name-field-to-patrons.patch (text/plain), 19.57 KB, created by
Nick Clemens (kidclamp)
on 2021-09-30 12:55:50 UTC
(
hide
)
Description:
Bug 28633: Add preferred name field to patrons
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2021-09-30 12:55:50 UTC
Size:
19.57 KB
patch
obsolete
>From 657f52b638a89a8044aaaaff98048699bc489287 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Wed, 21 Jul 2021 10:44:12 +0000 >Subject: [PATCH] Bug 28633: Add preferred name field to patrons > >This patch adds a new field 'preferredname' to the patron record. > >Additionally it adds a method 'effective_name' to choose the preferred name if present >and fall back to firstname > >To test: >1 - Apply patches >2 - Update database and restart all, clear browser cache >3 - Load a patron in staff module >4 - Confirm you see and can add a preferred name >5 - Confirm the preferred name now displays on patron details >6 - Edit sysprefs BorrowerMandatoryFields and BorrowerUnwantedFields to confirm you can make > new field required or hidden >7 - Sign in as patron to opac >8 - Confirm preferred name shows >9 - Edit account on opac and confirm field is present >--- > Koha/Patron.pm | 13 ++++++++++ > installer/data/mysql/kohastructure.sql | 3 +++ > koha-tmpl/intranet-tmpl/prog/en/columns.def | 1 + > .../prog/en/includes/patron-title.inc | 13 ++++++++-- > .../prog/en/includes/patronfields.inc | 1 + > .../modules/admin/preferences/borrowers.json | 1 + > .../prog/en/modules/members/memberentrygen.tt | 17 ++++++++++++- > .../prog/en/modules/members/members-update.tt | 1 + > .../prog/en/modules/members/moremember.tt | 2 +- > .../bootstrap/en/includes/patron-title.inc | 2 +- > .../bootstrap/en/modules/opac-memberentry.tt | 15 ++++++++--- > t/db_dependent/Koha/Patron.t | 25 ++++++++++++++++++- > 12 files changed, 85 insertions(+), 9 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 941dace0df..ea09167403 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -102,6 +102,19 @@ sub new { > return $class->SUPER::new($params); > } > >+=head3 effective_name >+ >+Return the preferred name for a patron, or their firstname if no >+preferred name is set >+ >+=cut >+ >+sub effective_name { >+ my ( $self ) = @_; >+ >+ return $self->preferredname || $self->firstname; >+} >+ > =head3 fixup_cardnumber > > Autogenerate next cardnumber from highest value found in database >diff --git a/installer/data/mysql/kohastructure.sql b/installer/data/mysql/kohastructure.sql >index b20feec57d..3a429fbe84 100644 >--- a/installer/data/mysql/kohastructure.sql >+++ b/installer/data/mysql/kohastructure.sql >@@ -1229,6 +1229,7 @@ CREATE TABLE `borrower_modifications` ( > `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL, > `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, > `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, >+ `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name', > `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, > `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, > `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, >@@ -1347,6 +1348,7 @@ CREATE TABLE `borrowers` ( > `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers', > `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)', > `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name', >+ `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name', > `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.', > `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower', > `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower', >@@ -2354,6 +2356,7 @@ CREATE TABLE `deletedborrowers` ( > `cardnumber` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'unique key, library assigned ID number for patrons/borrowers', > `surname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s last name (surname)', > `firstname` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s first name', >+ `preferredname` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s preferred name', > `title` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'patron/borrower''s title, for example: Mr. or Mrs.', > `othernames` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'any other names associated with the patron/borrower', > `initials` mediumtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'initials for your patron/borrower', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/columns.def b/koha-tmpl/intranet-tmpl/prog/en/columns.def >index a8d15914c1..1accc028cf 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/columns.def >+++ b/koha-tmpl/intranet-tmpl/prog/en/columns.def >@@ -2,6 +2,7 @@ > <field name="borrowers.title">Salutation</field> > <field name="borrowers.surname">Surname</field> > <field name="borrowers.firstname">First name</field> >+<field name="borrowers.preferredname">Preferred name</field> > <field name="borrowers.dateofbirth">Date of birth</field> > <field name="borrowers.initials">Initials</field> > <field name="borrowers.othernames">Other name</field> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc >index 71a293588a..576b6794c6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-title.inc >@@ -7,6 +7,8 @@ > [%- SET data.surname = patron.surname -%] > [%- SET data.othernames = patron.othernames -%] > [%- SET data.firstname = patron.firstname -%] >+ [%- SET data.preferredname = patron.preferredname -%] >+ [%- SET data.effective_name = patron.effective_name -%] > [%- SET data.cardnumber = patron.cardnumber -%] > [%- SET data.borrowernumber = patron.borrowernumber -%] > [%- SET data.title = patron.title -%] >@@ -15,6 +17,8 @@ > [%- SET data.surname = borrower.surname -%] > [%- SET data.othernames = borrower.othernames -%] > [%- SET data.firstname = borrower.firstname -%] >+ [%- SET data.preferredname = borrower.preferredname -%] >+ [%- SET data.effective_name = borrower.effective_name -%] > [%- SET data.cardnumber = borrower.cardnumber -%] > [%- SET data.borrowernumber = borrower.borrowernumber -%] > [%- SET data.title = borrower.title -%] >@@ -23,10 +27,15 @@ > [%- SET data.surname = surname -%] > [%- SET data.othernames = othernames -%] > [%- SET data.firstname = firstname -%] >+ [%- SET data.preferredname = preferredname -%] >+ [%- SET data.effective_name = effective_name -%] > [%- SET data.cardnumber = cardnumber -%] > [%- SET data.borrowernumber = borrowernumber -%] > [%- SET data.title = title -%] > [%- END -%] >+[%- UNLESS data.effective_name -%] >+ [%- SET data.effective_name = data.preferredname || data.firstname -%] >+[%- END -%] > [%# Parameter no_html - if 1, the html tags are NOT generated %] > [%- IF no_title %][% SET data.title = "" %][% END -%] > [%- IF data.title %] >@@ -60,9 +69,9 @@ > [%- IF data.category_type == 'I' -%] > [%- data.surname | html %] [% IF data.othernames %] ([% data.othernames | html %])[% END -%] > [%- ELSIF invert_name -%] >- [% data.title | $raw %][%- data.surname | html %][% IF ( data.firstname ) %], [% data.firstname | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%] >+ [% data.title | $raw %][%- data.surname | html %][% IF ( data.effective_name ) %], [% data.effective_name | html %][% END %][% IF data.othernames %] ([% data.othernames | html %]) [% END -%] > [%- ELSE -%] >- [% data.title | $raw %][%- data.firstname | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%] >+ [% data.title | $raw %][%- data.effective_name | html %] [% IF data.othernames %] ([% data.othernames | html %]) [% END %] [% data.surname | html -%] > [%- END -%] > [%- IF display_cardnumber AND data.cardnumber %] ([% data.cardnumber | html %])[% END -%] > [%- ELSIF display_cardnumber -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc >index 7edc5c9082..e9b2680e46 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patronfields.inc >@@ -5,6 +5,7 @@ > [%- CASE 'cardnumber' -%]<span>Card number</span> > [%- CASE 'surname' -%]<span>Surname</span> > [%- CASE 'firstname' -%]<span>First name</span> >+ [%- CASE 'firstname' -%]<span>Preferred name</span> > [%- CASE 'title' -%]<span>Salutation</span> > [%- CASE 'othernames' -%]<span>Other name</span> > [%- CASE 'initials' -%]<span>Initials</span> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json >index 23140978f0..d4b5e7c230 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/borrowers.json >@@ -2,6 +2,7 @@ > "cardnumber": "cardnumber", > "surname": "surname", > "firstname": "firstname", >+ "preferredname": "preferredname", > "title": "title", > "othernames": "othernames", > "initials": "initials", >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >index 451ffaeee5..79c7d56a78 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt >@@ -264,7 +264,7 @@ legend:hover { > [% END %] > > [% IF ( step_1 ) %] >- [% UNLESS notitle && nosurname && nofirstname && nodateofbirth && noinitials && noothernames &&nosex %] >+ [% UNLESS notitle && nosurname && nofirstname && nopreferredname && nodateofbirth && noinitials && noothernames &&nosex %] > <fieldset class="rows" id="memberentry_identity"> > <legend id="identity_lgd">[% IF ( I ) %]Organization [% ELSE %]Patron [% END %]identity</legend> > <ol> >@@ -338,6 +338,21 @@ legend:hover { > [% END %] > </li> > [% END #/UNLESS nofirstname %] >+ [% UNLESS nopreferredname %] >+ <li> >+ [% IF ( mandatorypreferredname ) %] >+ <label for="preferredname" class="required"> >+ [% ELSE %] >+ <label for="preferredname"> >+ [% END %] >+ Preferred name: >+ </label> >+ <input type="text" id="preferredname" name="preferredname" size="20" value="[% preferredname | html UNLESS opduplicate %]" /> >+ [% IF ( mandatorypreferredname ) %] >+ <span class="required">Required</span> >+ [% END %] >+ </li> >+ [% END #/UNLESS nopreferredname %] > [% UNLESS nodateofbirth %] > <li> > [% IF ( mandatorydateofbirth ) %] >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 6e90e23687..b99abaca0f 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 >@@ -19,6 +19,7 @@ > [% CASE 'branchcode' %]<span>Home library (branchcode)</span> > [% CASE 'surname' %]<span>Surname</span> > [% CASE 'firstname' %]<span>First name</span> >+[% CASE 'preferredname' %]<span>Preferred name</span> > [% CASE 'title' %]<span>Title</span> > [% CASE 'othernames' %]<span>Other names</span> > [% CASE 'initials' %]<span>Initials</span> >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 300d642bea..ee7558cb06 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -86,7 +86,7 @@ > > <h3> > [% UNLESS ( I ) %] >- [% patron.title | html %] [% patron.firstname | html %] >+ [% patron.title | html %] [% patron.effective_name | html %] > [% END %] > [% patron.surname | html %] ([% patron.cardnumber | html %]) > </h3> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc >index d77961d713..4b87c83aaa 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/patron-title.inc >@@ -4,5 +4,5 @@ > [%- IF patron.title -%] > <span class="patron-title">[% patron.title | html %]</span> > [%- END -%] >- [% patron.firstname | html %] [% patron.surname | html %] >+ [% patron.effective_name | html %] [% patron.surname | html %] > [%- END -%] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >index 790f1e5044..309ecf1ea3 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt >@@ -173,7 +173,7 @@ > Guaranteed by > [% FOREACH gr IN patron.guarantor_relationships %] > [% SET g = gr.guarantor %] >- [% g.firstname | html %] [% g.surname | html %] >+ [% g.effective_name | html %] [% g.surname | html %] > [%- IF ! loop.last %], [% END %] > [% END %] > </span> >@@ -190,7 +190,7 @@ > > <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form" autocomplete="off"> > >- [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' ] %] >+ [% FOREACH field = ['streetnumber' 'streettype' 'cardnumber' 'branchcode' 'categorycode' 'title' 'surname' 'firstname' 'preferredname' 'dateofbirth' 'initials' 'othernames' 'address' 'address2' 'city' 'state' 'zipcode' 'country' 'phone' 'phonepro' 'mobile' 'email' 'emailpro' 'fax' 'B_streettype' 'B_address' 'B_address2' 'B_city' 'B_state' 'B_zipcode' 'B_country' 'B_phone' 'B_email' 'contactnote' 'altcontactsurname' 'altcontactfirstname' 'altcontactaddress1' 'altcontactaddress2' 'altcontactaddress3' 'altcontactstate' 'altcontactzipcode' 'altcontactcountry' 'altcontactphone' 'password' ] %] > [% IF mandatory.defined( field ) %] > [% SET required.$field = 'required' %] > [% END %] >@@ -294,7 +294,7 @@ > [% END # / defined 'branchcode' %] > > [%# Following on one line for translatability %] >- [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %] >+ [% UNLESS hidden.defined('title') && hidden.defined('surname') && hidden.defined('firstname') && hidden.defined('preferredname') && hidden.defined('dateofbirth') && hidden.defined('initials') && hidden.defined('othernames') && hidden.defined('sex') %] > <div class="row"> > <div class="col"> > <fieldset class="rows" id="memberentry_identity"> >@@ -337,6 +337,15 @@ > </li> > [% END %] > >+ [% UNLESS hidden.defined('preferredname') %] >+ <li> >+ <label for="borrower_preferredname" class="[% required.preferredname | html %]">Preferrred name:</label> >+ >+ <input type="text" id="borrower_preferredname" name="borrower_preferredname" value="[% borrower.preferredname | html %]" class="[% required.preferredname | html %]" /> >+ <div class="required_label [% required.preferredname | html %]">Required</div> >+ </li> >+ [% END %] >+ > [% UNLESS hidden.defined('dateofbirth') %] > <li> > <label for="borrower_dateofbirth" class="[% required.dateofbirth | html %]">Date of birth:</label> >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index f5a329960d..74a63dcfbe 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 8; >+use Test::More tests => 9; > use Test::Exception; > use Test::Warn; > >@@ -716,3 +716,26 @@ subtest 'can_log_into() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'effective_name() tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron_1 = $builder->build_object({ class => 'Koha::Patrons', value => { >+ firstname => 'John', >+ preferredname => 'Jacob', >+ } >+ }); >+ my $patron_2 = $builder->build_object({ class => 'Koha::Patrons', value=> { >+ firstname => "Bob", >+ preferredname => undef, >+ } >+ }); >+ >+ is( $patron_1->effective_name, "Jacob", 'Preferred name correctly chosen' ); >+ is( $patron_2->effective_name, "Bob", 'First name correctly chosen if no preferred name' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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 28633
:
123008
|
123009
|
123010
|
123658
|
125497
|
125498
|
125499
|
125500
|
126591
|
128968
|
128969
|
128970
|
130000
|
130001
|
130002
|
133445
|
133446
|
133447
|
133448
|
133449
|
133450
|
133451
|
133958
|
133959
|
133960
|
133961
|
133962
|
133963
|
133964
|
133965
|
166792
|
166793
|
166794
|
166813
|
166814
|
166815
|
166816
|
166817
|
167163
|
167164
|
173628
|
173629
|
173630
|
173631
|
173632
|
173633
|
173634
|
173664
|
173665
|
173666
|
173667
|
173668
|
173669
|
173670
|
173717
|
173718
|
173719
|
173813
|
173814
|
173815
|
173816
|
173826
|
173827
|
173828
|
173829
|
173930
|
173931
|
173932
|
173933
|
173934
|
173935
|
173936
|
174419
|
174420
|
174472
|
175177