Bugzilla – Attachment 57047 Details for
Bug 17522
opac-user.pl gives error of OpacRenewalAllowed is enabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17522 - opac-user.pl gives error of OpacRenewalAllowed is enabled
Bug-17522---opac-userpl-gives-error-of-OpacRenewal.patch (text/plain), 9.56 KB, created by
Kyle M Hall (khall)
on 2016-11-01 15:43:01 UTC
(
hide
)
Description:
Bug 17522 - opac-user.pl gives error of OpacRenewalAllowed is enabled
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2016-11-01 15:43:01 UTC
Size:
9.56 KB
patch
obsolete
>From 211112bd84d64bff89993c25962f4583a260e4bd Mon Sep 17 00:00:00 2001 >From: Kyle M Hall <kyle@bywatersolutions.com> >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 %] >+ > <div class="main"> > <ul class="breadcrumb"> > <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">›</span></li> >@@ -156,7 +159,7 @@ Using this account is not recommended because some parts of Koha will not functi > <th>Barcode</th> > [% END %] > <th>Call no.</th> >- [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] >+ [% IF ( OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %] > <th class="nosort">Renew</th> > [% END %] > [% IF ( OPACFinesTab ) %] >@@ -245,7 +248,7 @@ Using this account is not recommended because some parts of Koha will not functi > <span class="tdlabel">Call no.:</span> > [% ISSUE.itemcallnumber %] > </td> >- [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] >+ [% IF ( OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %] > <td class="renew"> > [% IF ISSUE.renewed %]<span class="blabel label-success">Renewed!</span><br />[% END %] > [% IF ( ISSUE.status ) %] >@@ -285,12 +288,12 @@ Using this account is not recommended because some parts of Koha will not functi > [% END # /FOREACH ISSUES %] > </tbody> > </table> >- [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] >+ [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %] > <input type="submit" class="btn" value="Renew selected" /> > [% END %] > </form> > >- [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] >+ [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %] > <form id="renewall" action="/cgi-bin/koha/opac-renew.pl" method="post"> > <input type="hidden" name="from" value="opac_user" /> > <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" /> >@@ -876,7 +879,7 @@ Using this account is not recommended because some parts of Koha will not functi > e.preventDefault(); > $("#renewall").submit(); > }); >- [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] >+ [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %] > $("#checkoutst caption").append("<div id=\"renewcontrols\"><a id=\"renewselected_link\" href=\"#\">"+_("Renew selected")+"</a> <a id=\"renewall_link\" href=\"#\">"+_("Renew all")+"</a></div>"); > [% END %] > [% END %] >diff --git a/t/Patron.t b/t/Patron.t >index c32de10..14a5b81 100755 >--- a/t/Patron.t >+++ b/t/Patron.t >@@ -17,14 +17,16 @@ > > use Modern::Perl; > >-use Test::More tests => 11; >+use Test::More tests => 13; > use Test::Warn; > use t::lib::Mocks; >+use t::lib::Mocks qw(mock_preference); > > BEGIN { > t::lib::Mocks::mock_dbh; > use_ok('Koha::Object'); > use_ok('Koha::Patron'); >+ use_ok('Koha::DateUtils'); > } > > my $object = Koha::Patron->new( { surname => 'Test Patron' } ); >@@ -324,4 +326,22 @@ subtest 'Set tests' => sub { > is( $patron->privacy, '667789', 'privacy field set ok' ); > }; > >+subtest 'is_expiry tests' => sub { >+ plan tests => 4; >+ >+ t::lib::Mocks::mock_preference( "dateformat", "iso" ); >+ >+ $patron->dateexpiry(undef); >+ ok( !$patron->is_expired, "Patron is not expired if expiry date is not set" ); >+ >+ $patron->dateexpiry("1900-01-01"); >+ ok( $patron->is_expired, "Patron is expired with expiry date 1900-01-01" ); >+ >+ $patron->dateexpiry("9999-01-01"); >+ ok( !$patron->is_expired, "Patron is not expired with expiry date 9999-01-01" ); >+ >+ $patron->dateexpiry( dt_from_string->ymd ); >+ ok( $patron->is_expired, "Patron is not expired if the expiration date is today's date" ); >+}; >+ > 1; >diff --git a/t/db_dependent/Patrons.t b/t/db_dependent/Patrons.t >index 24707df..1e308c1 100755 >--- a/t/db_dependent/Patrons.t >+++ b/t/db_dependent/Patrons.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 17; >+use Test::More tests => 18; > use Test::Warn; > > use C4::Context; >@@ -104,4 +104,45 @@ foreach my $b ( $patrons->as_list() ) { > is( $b->categorycode(), $categorycode, "Iteration returns a patron object" ); > } > >+subtest 'should_block_expired_patron_opac_actions tests' => sub { >+ plan tests => 2; >+ >+ C4::Context->set_preference( "BlockExpiredPatronOpacActions", "TEST" ); >+ >+ my $patron_category_syspref = Koha::Patron::Category->new( >+ { >+ categorycode => 'FollowPref', >+ BlockExpiredPatronOpacActions => -1, >+ } >+ )->store(); >+ >+ my $patron_syspref = Koha::Patron->new( >+ { >+ surname => 'Test', >+ branchcode => $branchcode, >+ categorycode => $patron_category_syspref->categorycode, >+ } >+ )->store(); >+ >+ my $patron_category_table = Koha::Patron::Category->new( >+ { >+ categorycode => 'FollowTbl', >+ BlockExpiredPatronOpacActions => 1, >+ } >+ )->store(); >+ >+ my $patron_table = Koha::Patron->new( >+ { >+ surname => 'Test', >+ branchcode => $branchcode, >+ categorycode => $patron_category_table->categorycode, >+ } >+ )->store(); >+ >+ is( $patron_syspref->should_block_expired_patron_opac_actions, >+ "TEST", "Category is following BlockExpiredPatronOpacActions syspref if category column BlockExpiredPatronOpacActions is set to -1" ); >+ >+ is( $patron_table->should_block_expired_patron_opac_actions, 1, "Category returns its' own value because it is not set to -1" ); >+}; >+ > 1; >-- >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 17522
:
56999
|
57047
|
57048
|
57102
|
57414
|
57415
|
57478
|
57505