From 6045114224bd4c25028908ccd1bcb780597c58a8 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Mon, 21 Nov 2022 10:56:22 +0100 Subject: [PATCH] Revert Bug 31421 Signed-off-by: Arthur Suzuki --- Koha/Template/Plugin/Categories.pm | 12 +-------- .../prog/en/includes/patron-toolbar.inc | 2 +- t/db_dependent/Template/Plugin/Categories.t | 26 ++++++------------- 3 files changed, 10 insertions(+), 30 deletions(-) diff --git a/Koha/Template/Plugin/Categories.pm b/Koha/Template/Plugin/Categories.pm index 4da8748ac4..db7b2fd0e2 100644 --- a/Koha/Template/Plugin/Categories.pm +++ b/Koha/Template/Plugin/Categories.pm @@ -24,11 +24,6 @@ use List::Util qw( any ); use Koha::Patron::Categories; sub all { - my ( $self, $params ) = @_; - return Koha::Patron::Categories->search($params); -} - -sub limited { my ( $self, $params ) = @_; return Koha::Patron::Categories->search_with_library_limits($params); } @@ -61,14 +56,9 @@ Koha::Template::Plugin::Categories - TT Plugin for categories =head2 all -In a template, you can get all the categories with +In a template, you can get the all categories with the following TT code: [% Categories.all() %] -=head2 limited - -In a template, you can get the categories with library limits applied with -the following TT code: [% Categories.limited() %] - =head2 GetName In a template, you can get the name of a patron category using diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc index e26c5e676d..4626a406c9 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-toolbar.inc @@ -1,7 +1,7 @@ [% INCLUDE 'blocking_errors.inc' %] [% USE Categories %] [% USE Koha %] -[% SET categories = Categories.limited %] +[% SET categories = Categories.all %] [% UNLESS ( no_add ) %]
diff --git a/t/db_dependent/Template/Plugin/Categories.t b/t/db_dependent/Template/Plugin/Categories.t index c409ccf57f..0d99a85465 100755 --- a/t/db_dependent/Template/Plugin/Categories.t +++ b/t/db_dependent/Template/Plugin/Categories.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 6; +use Test::More tests => 4; use t::lib::Mocks; use t::lib::TestBuilder; @@ -31,35 +31,25 @@ my $schema = Koha::Database->new->schema; $schema->storage->txn_begin; my $builder = t::lib::TestBuilder->new; + my $nb_categories = Koha::Patron::Categories->count; # Create sample categories -my $category_1 = $builder->build_object( { class => 'Koha::Patron::Categories' } ); -my @categories = Koha::Template::Plugin::Categories->new->all->as_list; +my $category_1 = $builder->build( { source => 'Category' } ); +my @categories = Koha::Template::Plugin::Categories->new->all; is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' ); -my $category_2 = $builder->build_object( { class => 'Koha::Patron::Categories' } ); -@categories = Koha::Template::Plugin::Categories->new->all->as_list; +my $category_2 = $builder->build( { source => 'Category' } ); +@categories = Koha::Template::Plugin::Categories->new->all; is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' ); is( Koha::Template::Plugin::Categories->GetName( - $category_1->categorycode + $category_1->{categorycode} ), - $category_1->description, + $category_1->{description}, '->GetName returns the right description' ); -my $library_1 = $builder->build_object( { class => 'Koha::Libraries' } ); -my $library_2 = $builder->build_object( { class => 'Koha::Libraries' } ); -$category_1->library_limits( [ $library_1->branchcode ] ); -$category_2->library_limits( [ $library_2->branchcode ] ); -t::lib::Mocks::mock_userenv( { branchcode => $library_1->branchcode } ); -my $limited = Koha::Template::Plugin::Categories->limited; -is( $limited->search( { 'me.categorycode' => $category_1->categorycode } )->count, - 1, 'Category 1 is available from library 1' ); -is( $limited->search( { 'me.categorycode' => $category_2->categorycode } )->count, - 0, 'Category 2 is not available from library 1' ); - $schema->storage->txn_rollback; subtest 'can_any_reset_password() tests' => sub { -- 2.39.5