Bugzilla – Attachment 60015 Details for
Bug 7534
Add an option on library level to indicate if a library can be chosen as pick-up location
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 7534: Add method Koha::Template::Plugin::Branches->pickup_locations
Bug-7534-Add-method-KohaTemplatePluginBranches-pic.patch (text/plain), 3.06 KB, created by
Lari Taskula
on 2017-02-08 14:52:05 UTC
(
hide
)
Description:
Bug 7534: Add method Koha::Template::Plugin::Branches->pickup_locations
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2017-02-08 14:52:05 UTC
Size:
3.06 KB
patch
obsolete
>From a47fb7b7f65ac112619092834afddcf9a3b0acf2 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Tue, 7 Feb 2017 19:40:38 +0200 >Subject: [PATCH] Bug 7534: Add method > Koha::Template::Plugin::Branches->pickup_locations > >This patch adds a new method Koha::Template::Plugin::Branches->pickup_locations. > >Unit tests included. > >To test: >1. prove t/db_dependent/Template/Plugin/Branches.t >--- > Koha/Template/Plugin/Branches.pm | 12 ++++++++++-- > t/db_dependent/Template/Plugin/Branches.t | 16 +++++++++++++++- > 2 files changed, 25 insertions(+), 3 deletions(-) > >diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm >index 3d17edc..75ed8f7 100644 >--- a/Koha/Template/Plugin/Branches.pm >+++ b/Koha/Template/Plugin/Branches.pm >@@ -59,10 +59,11 @@ sub all { > my ( $self, $params ) = @_; > my $selected = $params->{selected}; > my $unfiltered = $params->{unfiltered} || 0; >+ my $search_params = $params->{search_params} || {}; > > my $libraries = $unfiltered >- ? Koha::Libraries->search( {}, { order_by => ['branchname'] } )->unblessed >- : Koha::Libraries->search_filtered( {}, { order_by => ['branchname'] } )->unblessed; >+ ? Koha::Libraries->search( $search_params, { order_by => ['branchname'] } )->unblessed >+ : Koha::Libraries->search_filtered( $search_params, { order_by => ['branchname'] } )->unblessed; > > for my $l ( @$libraries ) { > if ( defined $selected and $l->{branchcode} eq $selected >@@ -75,4 +76,11 @@ sub all { > return $libraries; > } > >+sub pickup_locations { >+ my ($self, $params) = @_; >+ $params->{search_params} ||= {}; >+ $params->{search_params}->{pickup_location} = 1; >+ return $self->all($params); >+} >+ > 1; >diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t >index 507cea9..00bb768 100644 >--- a/t/db_dependent/Template/Plugin/Branches.t >+++ b/t/db_dependent/Template/Plugin/Branches.t >@@ -16,7 +16,7 @@ > > use Modern::Perl; > >-use Test::More tests => 15; >+use Test::More tests => 17; > > use C4::Context; > use Koha::Database; >@@ -75,6 +75,20 @@ is( grep ( { $_->{branchcode} eq 'ANOTHERLIB' and $_->{selected} == 1 } @$librar > $libraries = $plugin->all( { selected => '' } ); > is( grep ( { exists $_->{selected} } @$libraries ), 0, 'With selected parameter set to an empty string, no library should be preselected' ); > >+my $total = @{$plugin->all}; >+my $pickupable = @{$plugin->pickup_locations}; >+my $yet_another_library = $builder->build({ >+ source => 'Branch', >+ value => { >+ branchcode => 'CANTPICKUP', >+ pickup_location => 0, >+ } >+}); >+is(@{$plugin->pickup_locations}, $pickupable, 'Adding a new library with pickups' >+ .' disabled does not increase the amount returned by ->pickup_locations'); >+is(@{$plugin->all}, $total+1, 'However, adding a new library increases' >+ .' the total amount gotten with ->all'); >+ > t::lib::Mocks::mock_preference( 'IndependentBranches', 1 ); > $libraries = $plugin->all(); > is( scalar(@$libraries), 1, 'If IndependentBranches is set, only 1 library should be returned' ); >-- >1.9.1
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 7534
:
60014
|
60015
|
60016
|
60017
|
60018
|
60022
|
60023
|
60781
|
60794
|
60795
|
60796
|
60797
|
60798
|
60799
|
60878
|
60879
|
60880
|
60881
|
60882
|
60883
|
61044
|
61045
|
61046
|
61047
|
61273
|
61274
|
61275
|
61276
|
61277
|
61278
|
61279
|
61280
|
77847
|
77848
|
77849
|
77850
|
77851
|
77852
|
77853
|
77854
|
77855
|
77856
|
78160
|
78161
|
78162
|
78163
|
78164
|
78165
|
78166
|
78167
|
78168
|
78169
|
78170
|
78171
|
78477
|
78478
|
78479
|
78480
|
78481
|
78482
|
78483
|
78484
|
78485
|
78486
|
78487
|
78488
|
78489
|
78495
|
78540
|
78548
|
84852