Bugzilla – Attachment 71501 Details for
Bug 18403
Hide patron information if not part of the logged in user library group
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18403: Add new method Koha::Library->library_group
Bug-18403-Add-new-method-KohaLibrary-librarygroup.patch (text/plain), 3.83 KB, created by
Jonathan Druart
on 2018-02-12 19:33:22 UTC
(
hide
)
Description:
Bug 18403: Add new method Koha::Library->library_group
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-02-12 19:33:22 UTC
Size:
3.83 KB
patch
obsolete
>From 6e14fd52761f709f0644fe3a59700895cb1e7f87 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 6 Apr 2017 16:09:46 -0300 >Subject: [PATCH] Bug 18403: Add new method Koha::Library->library_group > >This is more a follow-up for bug 15707. It could be moved on its own bug report >if necessary. > >Test plan: > prove t/db_dependent/LibraryGroups.t >should return green > >Signed-off-by: Signed-off-by: Jon McGowan <jon.mcgowan@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > Koha/Library.pm | 12 ++++++++++++ > t/db_dependent/LibraryGroups.t | 17 ++++++++++++++++- > 2 files changed, 28 insertions(+), 1 deletion(-) > >diff --git a/Koha/Library.pm b/Koha/Library.pm >index 5862aa8b8c..9e6d616036 100644 >--- a/Koha/Library.pm >+++ b/Koha/Library.pm >@@ -56,6 +56,18 @@ sub get_effective_marcorgcode { > return $self->marcorgcode || C4::Context->preference("MARCOrgCode"); > } > >+=head3 library_groups >+ >+Return the Library groups of this library >+ >+=cut >+ >+sub library_groups { >+ my ( $self ) = @_; >+ my $rs = $self->_result->library_groups; >+ return Koha::Library::Groups->_new_from_dbic( $rs ); >+} >+ > =head2 Internal methods > > =head3 _type >diff --git a/t/db_dependent/LibraryGroups.t b/t/db_dependent/LibraryGroups.t >index 52bde2050b..69c6fa03ce 100644 >--- a/t/db_dependent/LibraryGroups.t >+++ b/t/db_dependent/LibraryGroups.t >@@ -4,7 +4,7 @@ use Modern::Perl; > > use List::MoreUtils 'any'; > >-use Test::More tests => 15; >+use Test::More tests => 16; > > use t::lib::TestBuilder; > >@@ -42,8 +42,10 @@ ok( $in_list, 'New root group is in the list returned by the get_root_groups met > my $groupA = Koha::Library::Group->new({ parent_id => $root_group->id, title => 'Group A' })->store(); > my $groupA1 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A1' })->store(); > my $groupA2 = Koha::Library::Group->new({ parent_id => $groupA->id, title => 'Group A2' })->store(); >+my $groupB = Koha::Library::Group->new({ parent_id => $root_group->id, title => 'Group B' })->store(); > > my $groupA_library1 = Koha::Library::Group->new({ parent_id => $groupA->id, branchcode => $library1->{branchcode} })->store(); >+my $groupB_library1 = Koha::Library::Group->new({ parent_id => $groupB->id, branchcode => $library1->{branchcode} })->store(); > my $groupA1_library2 = Koha::Library::Group->new({ parent_id => $groupA1->id, branchcode => $library2->{branchcode} })->store(); > > my @children = $root_group->children()->as_list(); >@@ -69,6 +71,19 @@ ok( !$in_list, 'Method libraries_not_direct_children returns all libraries not d > $in_list = any { $_->id eq $groupA1_library2->branchcode } @libraries_not_direct_children; > ok( $in_list, 'Method libraries_not_direct_children returns all libraries not direct descendants of group, library 2 is in the list'); > >+subtest 'Koha::Library->library_groups' => sub { >+ plan tests => 4; >+ my $library3 = Koha::Libraries->find( $library3->{branchcode} ); >+ my $groups = $library3->library_groups; >+ is( ref( $groups ), 'Koha::Library::Groups', 'Koha::Library->library_groups should return Koha::Library::Groups' ); >+ is( $groups->count, 0, 'Library 3 should not be part of any groups'); >+ >+ my $library1 = Koha::Libraries->find( $library1->{branchcode} ); >+ $groups = $library1->library_groups; >+ is( ref( $groups ), 'Koha::Library::Groups', 'Koha::Library->library_groups should return Koha::Library::Groups' ); >+ is( $groups->count, 2, 'Library 1 should be part of 2 groups' ); >+}; >+ > my $groupX = Koha::Library::Group->new( { title => "Group X" } )->store(); > my $groupX_library1 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library1->{branchcode} })->store(); > my $groupX_library2 = Koha::Library::Group->new({ parent_id => $groupX->id, branchcode => $library2->{branchcode} })->store(); >-- >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 18403
:
62010
|
62011
|
62012
|
62013
|
62014
|
62015
|
62016
|
62017
|
62018
|
62019
|
62020
|
62021
|
62022
|
62023
|
62024
|
62025
|
62026
|
62027
|
62028
|
62029
|
62030
|
62031
|
62032
|
62033
|
62302
|
62303
|
62830
|
62831
|
62832
|
62833
|
62834
|
62835
|
62836
|
62837
|
62838
|
62839
|
62840
|
62841
|
62842
|
62843
|
62844
|
62845
|
62846
|
62847
|
62848
|
62849
|
62850
|
62851
|
62852
|
62853
|
62854
|
62855
|
71392
|
71394
|
71500
| 71501 |
71502
|
71503
|
71504
|
71505
|
71506
|
71507
|
71508
|
71509
|
71510
|
71511
|
71512
|
71513
|
71514
|
71515
|
71516
|
71517
|
71518
|
71519
|
71520
|
71521
|
71522
|
71523
|
71524
|
71525
|
71526
|
71527
|
71528
|
71529
|
71530
|
71767