Bugzilla – Attachment 91098 Details for
Bug 17492
Show warning if patron's age is out of category limits
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17492: Add a warning about age being of-limits and a button to update it
Bug-17492-Add-a-warning-about-age-being-of-limits-.patch (text/plain), 9.98 KB, created by
Nick Clemens (kidclamp)
on 2019-06-28 15:16:01 UTC
(
hide
)
Description:
Bug 17492: Add a warning about age being of-limits and a button to update it
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-06-28 15:16:01 UTC
Size:
9.98 KB
patch
obsolete
>From fc8f9fc14195be8eaf86252bd2896b51e2dcee5b Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Radek=20=C5=A0iman?= <rbit@rbit.cz> >Date: Mon, 24 Oct 2016 03:41:02 +0200 >Subject: [PATCH] Bug 17492: Add a warning about age being of-limits and a > button to update it >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds a warning if a patron's age is out of limits if an assigned category. >It also adds a button allowing to change the category. > >Test plan: >1) Apply patch >2) Create a patron and assign him a category having age limits set >3) Change patron's age to be older/younger than category's limits >4) At "Check out" and "Details" tabs you should see a warning with a >button allowing to change the category, eg.: > - http://prntscr.com/cz7ch3 > - http://prntscr.com/cz7em4 > - http://prntscr.com/cz7dj1 >5) Set a valid category according to patron's age >6) Warning should disappear >7) Perform similar test again, but instead of changing the age change >the limits of a category >8) During tests verify "Change category" button everytime opens "Modify >patron" page: > http://prntscr.com/cz7g5q >9) Ensure that left-side panel is always on its expected place >10) Remove patron's date of birth and test that all categories are >allowed now >11) Run automated tests: prove t/db_dependent/Koha/Patron.t > >Signed-off-by: Marc Véron <veron@veron.ch> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >Signed-off-by: Michal Denar <black23@gmail.com> > >Signed-off-by: Michal Denar <black23@gmail.com> >--- > Koha/Patron.pm | 18 +++++++ > circ/circulation.pl | 7 +++ > .../prog/en/includes/category-out-of-age-limit.inc | 4 ++ > .../prog/en/modules/circ/circulation.tt | 4 ++ > .../prog/en/modules/members/moremember.tt | 9 +++- > members/moremember.pl | 8 +++ > t/db_dependent/Koha/Patrons.t | 60 +++++++++++++++++++++- > 7 files changed, 107 insertions(+), 3 deletions(-) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index 04b54a3ed6..06124a8ccf 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -977,6 +977,24 @@ sub get_age { > return $age; > } > >+=head3 is_category_valid >+ >+my $is_valid = $patron->is_category_valid >+ >+Return 1 if patron's age is between allowed limits, returns 0 if it's not. >+ >+=cut >+ >+sub is_category_valid { >+ my ($self) = @_; >+ my $age = $self->get_age; >+ >+ my $patroncategory = $self->category; >+ my ($low,$high) = ($patroncategory->dateofbirthrequired, $patroncategory->upperagelimit); >+ >+ return (defined($age) && (($high && ($age > $high)) or ($age < $low))) ? 0 : 1; >+} >+ > =head3 account > > my $account = $patron->account >diff --git a/circ/circulation.pl b/circ/circulation.pl >index 43ce1aa41b..7191654e70 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -320,6 +320,13 @@ if ($patron) { > } > } > >+ # Calculate and display patron's age >+ if ( !$patron->is_category_valid ) { >+ $template->param( age_limitations => 1 ); >+ $template->param( age_low => $patron->category->dateofbirthrequired ); >+ $template->param( age_high => $patron->category->upperagelimit ); >+ } >+ > } > > # >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc >new file mode 100644 >index 0000000000..2f09139dbf >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/category-out-of-age-limit.inc >@@ -0,0 +1,4 @@ >+ <li> >+ <span class="circ-hlt">Patron's age is incorrect for their category.</span> >+ Ages allowed are [% age_low %]-[% age_high %]. >+ <a href="/cgi-bin/koha/members/memberentry.pl?op=modify&borrowernumber=[% borrowernumber %]&step=3" class="btn btn-default btn-xs">Change category</a></li> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index 41dec3b814..a502470d5f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -743,6 +743,10 @@ > [% INCLUDE 'blocked-fines.inc' fines = chargesamount %] > [% END %] > >+ [% IF age_limitations %] >+ [% INCLUDE 'category-out-of-age-limit.inc' %] >+ [% END %] >+ > [% IF ( charges_guarantees ) %] > <li> > <span class="circ-hlt">Fees & Charges:</span> Patron's guarantees collectively owe [% chargesamount_guarantees | $Price %]. >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 e967d56f68..05cb6c9478 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -71,10 +71,15 @@ > </div> > [% END %] > >- [% IF fines %] >+ [% IF fines || age_limitations %] > <div id="circmessages" class="circmessage attention"> > <ul> >- [% INCLUDE 'blocked-fines.inc' %] >+ [% IF fines %] >+ [% INCLUDE 'blocked-fines.inc' %] >+ [% END %] >+ [% IF age_limitations %] >+ [% INCLUDE 'category-out-of-age-limit.inc' %] >+ [% END %] > </ul> > </div> > [% END %] >diff --git a/members/moremember.pl b/members/moremember.pl >index 1f63180e58..defd5d466f 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -119,6 +119,14 @@ if ( my $guarantor = $patron->guarantor ) { > my $relatives_issues_count = > Koha::Checkouts->count({ borrowernumber => \@relatives }); > >+# Calculate and display patron's age >+if ( !$patron->is_category_valid ) { >+ $template->param( age_limitations => 1 ); >+ $template->param( age_low => $patron->category->dateofbirthrequired ); >+ $template->param( age_high => $patron->category->upperagelimit ); >+} >+$template->param( age => $patron->get_age ); >+ > # Generate CSRF token for upload and delete image buttons > $template->param( > csrf_token => Koha::Token->new->generate_csrf({ session_id => $input->cookie('CGISESSID'),}), >diff --git a/t/db_dependent/Koha/Patrons.t b/t/db_dependent/Koha/Patrons.t >index a73b8e819d..75b91cc4c7 100644 >--- a/t/db_dependent/Koha/Patrons.t >+++ b/t/db_dependent/Koha/Patrons.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 39; >+use Test::More tests => 40; > use Test::Warn; > use Test::Exception; > use Test::MockModule; >@@ -639,6 +639,64 @@ subtest 'get_age' => sub { > $patron->delete; > }; > >+subtest 'is_category_valid' => sub { >+ plan tests => 10; >+ >+ my $today = dt_from_string; >+ >+ my $category = $builder->build({ >+ source => 'Category', >+ value => { >+ categorycode => 'AGE_5_10', >+ dateofbirthrequired => 5, >+ upperagelimit => 10 >+ } >+ }); >+ $category = Koha::Patron::Categories->find( $category->{categorycode} ); >+ >+ my $patron = $builder->build({ >+ source => 'Borrower', >+ value => { >+ categorycode => 'AGE_5_10' >+ } >+ }); >+ $patron = Koha::Patrons->find( $patron->{borrowernumber} ); >+ >+ >+ $patron->dateofbirth( undef ); >+ is( $patron->is_category_valid, 1, 'Patron with no dateofbirth is always valid for any category'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -12, months => -6, days => -1 ) ); >+ is( $patron->is_category_valid, 0, 'Patron is 12, so the age is above allowed range 5-10 years'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -3, months => -6, days => -1 ) ); >+ is( $patron->is_category_valid, 0, 'Patron is 3, so the age is below allowed range 5-10 years'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -7, months => -6, days => -1 ) ); >+ is( $patron->is_category_valid, 1, 'Patron is 7, so the age perfectly suits allowed range 5-10 years'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 0 ) ); >+ is( $patron->is_category_valid, 1, 'Patron celebrates the 5th birthday today, so the age is allowed for this category'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => 1 ) ); >+ is( $patron->is_category_valid, 0, 'Patron will celebrate the 5th birthday tomorrow, so the age is NOT allowed for this category'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -5, months => 0, days => -1 ) ); >+ is( $patron->is_category_valid, 1, 'Patron celebrated the 5th birthday yesterday, so the age is allowed for this category'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 0 ) ); >+ is( $patron->is_category_valid, 0, 'Patron celebrate the 11th birthday today, so the age is NOT allowed for this category'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => 1 ) ); >+ is( $patron->is_category_valid, 1, 'Patron will celebrate the 11th birthday tomorrow, so the age is allowed for this category'); >+ >+ $patron->dateofbirth( $today->clone->add( years => -11, months => 0, days => -1 ) ); >+ is( $patron->is_category_valid, 0, 'Patron celebrated the 11th birthday yesterday, so the age is NOT allowed for this category'); >+ >+ $patron->delete; >+ $category->delete; >+}; >+ > subtest 'account' => sub { > plan tests => 1; > >-- >2.11.0
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 17492
:
56805
|
56806
|
56874
|
56933
|
56934
|
56935
|
56936
|
56937
|
56976
|
56985
|
56986
|
56987
|
56988
|
56989
|
56990
|
56995
|
62860
|
67040
|
67041
|
67042
|
67850
|
67851
|
67867
|
67868
|
68139
|
68140
|
68141
|
68142
|
68143
|
68144
|
68145
|
91028
|
91029
|
91044
|
91045
| 91098 |
91099
|
91100