From 211112bd84d64bff89993c25962f4583a260e4bd Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Mon, 31 Oct 2016 14:04:01 +0000 Subject: [PATCH] Bug 17522 - opac-user.pl gives error of OpacRenewalAllowed is enabled If OpacRenewalAllowed is enabled, the following error message is displayed: Template process failed: undef error - The method is_expired is not covered by tests! at /home/vagrant/kohaclone/C4/Templates.pm line 121. Test Plan: 1) Check out an item for a patron 2) Enable OpacRenewalAllowed 3) Log in as that patron, go to opac-user.pl 4) Note the error 5) Apply this patch 6) Reload opac-user.pl 7) Page should now load! --- Koha/Patron.pm | 32 ++++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 13 ++++--- t/Patron.t | 22 ++++++++++- t/db_dependent/Patrons.t | 43 +++++++++++++++++++++- 4 files changed, 103 insertions(+), 7 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 9a2fd18..c1afb89 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -266,6 +266,21 @@ sub is_debarred { return; } +=head2 is_expired + +my $is_expired = $patron->is_expired; + +Returns true if the patron is passed the expiry date, false otherwise + +=cut + +sub is_expired { + my ($self) = @_; + + return 1 if $self->dateexpiry && dt_from_string( $self->dateexpiry ) < dt_from_string; + return 0; +} + =head2 update_password my $updated = $patron->update_password( $userid, $password ); @@ -449,6 +464,23 @@ sub add_enrolment_fee_if_needed { return $enrolment_fee || 0; } +=head3 should_block_expired_patron_opac_actions + +=cut + +sub should_block_expired_patron_opac_actions { + my ($self) = @_; + + my $patron_category = Koha::Patron::Categories->find( $self->categorycode ); + + if ( $patron_category->BlockExpiredPatronOpacActions == -1 ) { + return C4::Context->preference('BlockExpiredPatronOpacActions'); + } + else { + return $patron_category->BlockExpiredPatronOpacActions; + } +} + =head3 type =cut diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt index 438cb10..5e41983 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -12,6 +12,9 @@ [% INCLUDE 'bodytag.inc' bodyid='opac-user' bodyclass='scrollto' %] [% INCLUDE 'masthead.inc' %] +[% SET BlockExpiredPatronOpacActions = borrower.should_block_expired_patron_opac_actions %] +[% SET IsExpired = IsExpired %] +