Bugzilla – Attachment 67851 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: (followup) Logic moved to Koha namespace
Bug-17492-followup-Logic-moved-to-Koha-namespace.patch (text/plain), 3.67 KB, created by
Radek Šiman (R-Bit Technology, s.r.o.)
on 2017-10-09 19:26:37 UTC
(
hide
)
Description:
Bug 17492: (followup) Logic moved to Koha namespace
Filename:
MIME Type:
Creator:
Radek Šiman (R-Bit Technology, s.r.o.)
Created:
2017-10-09 19:26:37 UTC
Size:
3.67 KB
patch
obsolete
>From ff40178c7654d208b6ab9a39d4ca8c6b36475b87 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Radek=20=C5=A0iman?= <rbit@rbit.cz> >Date: Mon, 2 Oct 2017 17:08:45 +0200 >Subject: [PATCH] Bug 17492: (followup) Logic moved to Koha namespace > >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 >--- > Koha/Patron.pm | 18 ++++++++++++++++++ > circ/circulation.pl | 10 +++------- > members/moremember.pl | 16 ++++------------ > 3 files changed, 25 insertions(+), 19 deletions(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index daa972c..d444111 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -568,6 +568,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 (($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 1f22bed..c002412 100755 >--- a/circ/circulation.pl >+++ b/circ/circulation.pl >@@ -304,14 +304,10 @@ if ($patron) { > } > > # Calculate and display patron's age >- my $age = $patron->get_age; >- >- my $patroncategory = $patron->category; >- my ($low,$high) = ($patroncategory->dateofbirthrequired, $patroncategory->upperagelimit); >- if (($high && ($age > $high)) or ($age < $low)) { >+ if ( !$patron->is_category_valid ) { > $template->param( age_limitations => 1 ); >- $template->param( age_low => $low ); >- $template->param( age_high => $high ); >+ $template->param( age_low => $patron->category->dateofbirthrequired ); >+ $template->param( age_high => $patron->category->upperagelimit ); > } > > } >diff --git a/members/moremember.pl b/members/moremember.pl >index fcf51f7..8d9815a 100755 >--- a/members/moremember.pl >+++ b/members/moremember.pl >@@ -246,20 +246,12 @@ my $overdues_exist = 0; > my $totalprice = 0; > > # Calculate and display patron's age >-my $age; >-if ( $data->{dateofbirth} ) { >- $age = Koha::Patron->new({ dateofbirth => $data->{dateofbirth} })->get_age; >- $template->param( age => $age ); >-} >- >-# Check patron's category against age >-my $patroncategory = Koha::Patron::Categories->find($data->{ 'categorycode' }); >-my ($low,$high) = ($patroncategory->dateofbirthrequired, $patroncategory->upperagelimit); >-if (($high && ($age > $high)) or ($age < $low)) { >+if ( !$patron->is_category_valid ) { > $template->param( age_limitations => 1 ); >- $template->param( age_low => $low ); >- $template->param( age_high => $high ); >+ $template->param( age_low => $patron->category->dateofbirthrequired ); >+ $template->param( age_high => $patron->category->upperagelimit ); > } >+$template->param( age => $patron->get_age ); > > > ### ############################################################################### >-- >2.1.4
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