Bugzilla – Attachment 86869 Details for
Bug 21890
Allow forgotten password functionality to be limited by patron category
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21890: Add can_any_reset_password() to the Categories TT plugin
Bug-21890-Add-cananyresetpassword-to-the-Categorie.patch (text/plain), 3.21 KB, created by
Liz Rea
on 2019-03-21 19:51:16 UTC
(
hide
)
Description:
Bug 21890: Add can_any_reset_password() to the Categories TT plugin
Filename:
MIME Type:
Creator:
Liz Rea
Created:
2019-03-21 19:51:16 UTC
Size:
3.21 KB
patch
obsolete
>From a5980bc90cf74575446438eca8248e9d7a04fa36 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 31 Jan 2019 16:27:10 -0300 >Subject: [PATCH] Bug 21890: Add can_any_reset_password() to the Categories TT > plugin > >This patch introduces a method to the Koha::Template::Plugin::Categories >TT plugin. This methods queries for categories filtering them by >effective_reset_password flag set, and returns a boolean representing the fact >that there's at least one category allowed. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/Template/Plugin/Categories.t >=> SUCCESS: Tests pass! >- Sign off :-D > >Caveat: this patch/tests require the schema to be updated > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >--- > Koha/Template/Plugin/Categories.pm | 11 +++++++++++ > t/db_dependent/Template/Plugin/Categories.t | 26 +++++++++++++++++++++++++- > 2 files changed, 36 insertions(+), 1 deletion(-) > >diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm >index 97165001e4..f12c660faf 100644 >--- a/Koha/Template/Plugin/Categories.pm >+++ b/Koha/Template/Plugin/Categories.pm >@@ -33,6 +33,12 @@ sub GetName { > return Koha::Patron::Categories->find( $categorycode )->description; > } > >+sub can_any_reset_password { >+ return ( grep { $_->effective_reset_password } @{ Koha::Patron::Categories->search->as_list } ) >+ ? 1 >+ : 0; >+} >+ > 1; > > =head1 NAME >@@ -57,6 +63,11 @@ the following TT code: [% Categories.all() %] > In a template, you can get the name of a patron category using > [% Categories.GetName( categorycode ) %]. > >+=head2 can_any_reset_password >+ >+Returns I<true> is any patron category has the I<effective_reset_password> evaluate to I<true>. >+Returns I<false> otherwise. >+ > =head1 AUTHOR > > Jonathan Druart <jonathan.druart@biblibre.com> >diff --git a/t/db_dependent/Template/Plugin/Categories.t b/t/db_dependent/Template/Plugin/Categories.t >index 6ea75f8d5f..93384deda4 100644 >--- a/t/db_dependent/Template/Plugin/Categories.t >+++ b/t/db_dependent/Template/Plugin/Categories.t >@@ -17,7 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; >+use t::lib::Mocks; > use t::lib::TestBuilder; > > use Koha::Patron::Categories; >@@ -57,3 +58,26 @@ is( Koha::Template::Plugin::Categories->GetName( > > $schema->storage->txn_rollback; > >+subtest 'can_any_reset_password() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ # Make sure all existing categories have reset_password set to 0 >+ Koha::Patron::Categories->update({ reset_password => 0 }); >+ >+ ok( !Koha::Template::Plugin::Categories->new->can_any_reset_password, 'No category is allowed to reset password' ); >+ >+ t::lib::Mocks::mock_preference( 'OpacResetPassword', 0 ); >+ >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories', value => { reset_password => 1 } }); >+ >+ ok( Koha::Template::Plugin::Categories->new->can_any_reset_password, 'There\'s at least a category that is allowed to reset password' ); >+ >+ $category->reset_password( undef )->store; >+ >+ ok( !Koha::Template::Plugin::Categories->new->can_any_reset_password, 'No category is allowed to reset password' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >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 21890
:
84595
|
84596
|
84597
|
84598
|
84631
|
84632
|
84633
|
84634
|
85001
|
85002
|
85003
|
85004
|
85005
|
85006
|
86843
|
86844
|
86845
|
86846
|
86847
|
86866
|
86867
|
86868
|
86869
|
86870
|
86911
|
87289
|
87290
|
87291
|
87292
|
87293
|
87294
|
87295