Bugzilla – Attachment 72238 Details for
Bug 18936
Move issuingrules into circulation_rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 18936: (follow-up) Fix tests, replace old get_onshelfholds_policy method
Bug-18936-follow-up-Fix-tests-replace-old-getonshe.patch (text/plain), 11.25 KB, created by
Jesse Weaver
on 2018-02-26 19:18:51 UTC
(
hide
)
Description:
Bug 18936: (follow-up) Fix tests, replace old get_onshelfholds_policy method
Filename:
MIME Type:
Creator:
Jesse Weaver
Created:
2018-02-26 19:18:51 UTC
Size:
11.25 KB
patch
obsolete
>From 1862e3aec63c737229a530220ffa2c52adc35fc5 Mon Sep 17 00:00:00 2001 >From: Jesse Weaver <pianohacker@gmail.com> >Date: Mon, 26 Feb 2018 12:17:16 -0700 >Subject: [PATCH] Bug 18936: (follow-up) Fix tests, replace old > get_onshelfholds_policy method > >--- > C4/Reserves.pm | 2 +- > Koha/CirculationRules.pm | 22 ++++++++++++++++++++++ > installer/onboarding.pl | 21 ++++++++++----------- > opac/opac-ISBDdetail.pl | 4 ++-- > opac/opac-MARCdetail.pl | 4 ++-- > opac/opac-detail.pl | 4 ++-- > opac/opac-reserve.pl | 4 ++-- > opac/opac-shelves.pl | 4 ++-- > reserve/request.pl | 4 ++-- > .../Holds/DisallowHoldIfItemsAvailable.t | 19 ++++++++----------- > t/db_dependent/Reserves.t | 13 ------------- > 11 files changed, 53 insertions(+), 48 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 6ebbb0d93f..22d5bc54ee 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -1133,7 +1133,7 @@ sub IsAvailableForItemLevelRequest { > $item->{withdrawn} || > ($item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems')); > >- my $on_shelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item_object, patron => $patron } ); >+ my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item_object, patron => $patron } ); > > if ( $on_shelf_holds == 1 ) { > return 1; >diff --git a/Koha/CirculationRules.pm b/Koha/CirculationRules.pm >index e3a4b8c0d0..798e89c220 100644 >--- a/Koha/CirculationRules.pm >+++ b/Koha/CirculationRules.pm >@@ -322,6 +322,28 @@ sub set_rules { > return $rule_objects; > } > >+=head3 get_onshelfholds_policy >+ >+ my $on_shelf_holds = Koha::CirculationRules->get_onshelfholds_policy({ item => $item, patron => $patron }); >+ >+=cut >+ >+sub get_onshelfholds_policy { >+ my ( $class, $params ) = @_; >+ my $item = $params->{item}; >+ my $itemtype = $item->effective_itemtype; >+ my $patron = $params->{patron}; >+ my $rule = Koha::CirculationRules->get_effective_rule( >+ { >+ categorycode => ( $patron ? $patron->categorycode : undef ), >+ itemtype => $itemtype, >+ branchcode => $item->holdingbranch, >+ rule_name => 'onshelfholds', >+ } >+ ); >+ return $rule ? $rule->rule_value : undef; >+} >+ > =head3 type > > =cut >diff --git a/installer/onboarding.pl b/installer/onboarding.pl >index 83859e77c2..4bff7cfa1f 100755 >--- a/installer/onboarding.pl >+++ b/installer/onboarding.pl >@@ -30,8 +30,6 @@ use Koha::DateUtils; > use Koha::Patron::Categories; > use Koha::Patron::Category; > use Koha::ItemTypes; >-use Koha::IssuingRule; >-use Koha::IssuingRules; > > #Setting variables > my $input = new CGI; >@@ -250,16 +248,17 @@ if ( $step == 5 ) { > branchcode => $branchcode, > categorycode => $categorycode, > itemtype => $itemtype, >- maxissueqty => $maxissueqty, >- renewalsallowed => $renewalsallowed, >- renewalperiod => $renewalperiod, >- issuelength => $issuelength, >- lengthunit => $lengthunit, >- onshelfholds => $onshelfholds, >+ rules => { >+ maxissueqty => $maxissueqty, >+ renewalsallowed => $renewalsallowed, >+ renewalperiod => $renewalperiod, >+ issuelength => $issuelength, >+ lengthunit => $lengthunit, >+ onshelfholds => $onshelfholds, >+ } > }; > >- my $issuingrule = Koha::IssuingRule->new($params); >- eval { $issuingrule->store; }; >+ eval { Koha::CirculationRules->set_rules( $params ) }; > > unless ($@) { > push @messages, { code => 'success_on_insert_circ_rule' }; >@@ -269,7 +268,7 @@ if ( $step == 5 ) { > } > } > >- $step++ if Koha::IssuingRules->count; >+ $step++ if Koha::CirculationRules->count; > } > > my $libraries = Koha::Libraries->search( {}, { order_by => ['branchcode'] }, ); >diff --git a/opac/opac-ISBDdetail.pl b/opac/opac-ISBDdetail.pl >index 40e9b71f4c..9b169908fd 100755 >--- a/opac/opac-ISBDdetail.pl >+++ b/opac/opac-ISBDdetail.pl >@@ -52,7 +52,7 @@ use C4::Reserves; > use C4::Acquisition; > use C4::Serials; # uses getsubscriptionfrom biblionumber > use C4::Koha; >-use Koha::IssuingRules; >+use Koha::CirculationRules; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; >@@ -180,7 +180,7 @@ for my $itm (@items) { > && !$itemtypes->{$itm->{'itype'}}->{notforloan} > && $itm->{'itemnumber'}; > >- $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) >+ $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; > } > >diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl >index ebb78a2982..66c8f6d7d2 100755 >--- a/opac/opac-MARCdetail.pl >+++ b/opac/opac-MARCdetail.pl >@@ -58,7 +58,7 @@ use C4::Acquisition; > use C4::Koha; > use List::MoreUtils qw( any uniq ); > use Koha::Biblios; >-use Koha::IssuingRules; >+use Koha::CirculationRules; > use Koha::Items; > use Koha::Patrons; > use Koha::RecordProcessor; >@@ -135,7 +135,7 @@ my $allow_onshelf_holds; > my $patron = Koha::Patrons->find( $loggedinuser ); > for my $itm (@all_items) { > my $item = Koha::Items->find( $itm->{itemnumber} ); >- $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >+ $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); > last if $allow_onshelf_holds; > } > >diff --git a/opac/opac-detail.pl b/opac/opac-detail.pl >index e7653d9310..693ad6beb4 100755 >--- a/opac/opac-detail.pl >+++ b/opac/opac-detail.pl >@@ -52,7 +52,7 @@ use C4::CourseReserves qw(GetItemCourseReservesInfo); > use Koha::Biblios; > use Koha::RecordProcessor; > use Koha::AuthorisedValues; >-use Koha::IssuingRules; >+use Koha::CirculationRules; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Acquisition::Orders; >@@ -674,7 +674,7 @@ if ( not $viewallitems and @items > $max_items_to_display ) { > && !$itemtypes->{$itm->{'itype'}}->{notforloan} > && $itm->{'itemnumber'}; > >- $allow_onshelf_holds = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) >+ $allow_onshelf_holds = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ) > unless $allow_onshelf_holds; > > # get collection code description, too >diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl >index 2be6991530..2c3b3c6c98 100755 >--- a/opac/opac-reserve.pl >+++ b/opac/opac-reserve.pl >@@ -36,7 +36,7 @@ use C4::Debug; > use Koha::AuthorisedValues; > use Koha::Biblios; > use Koha::DateUtils; >-use Koha::IssuingRules; >+use Koha::CirculationRules; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Checkouts; >@@ -536,7 +536,7 @@ foreach my $biblioNum (@biblionumbers) { > CanItemBeReserved($borrowernumber,$itemNum) eq 'OK'; > > if ($policy_holdallowed) { >- my $opac_hold_policy = Koha::IssuingRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); >+ my $opac_hold_policy = Koha::CirculationRules->get_opacitemholds_policy( { item => $item, patron => $patron } ); > if ( $opac_hold_policy ne 'N' ) { # If Y or F > $itemLoopIter->{available} = 1; > $numCopiesOPACAvailable++; >diff --git a/opac/opac-shelves.pl b/opac/opac-shelves.pl >index b2799ea023..abaf3b95c6 100755 >--- a/opac/opac-shelves.pl >+++ b/opac/opac-shelves.pl >@@ -31,7 +31,7 @@ use C4::XSLT; > > use Koha::Biblios; > use Koha::Biblioitems; >-use Koha::IssuingRules; >+use Koha::CirculationRules; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Patrons; >@@ -320,7 +320,7 @@ if ( $op eq 'view' ) { > > my $items = $biblio->items; > while ( my $item = $items->next ) { >- $this_item->{allow_onshelf_holds} = Koha::IssuingRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); >+ $this_item->{allow_onshelf_holds} = Koha::CirculationRules->get_onshelfholds_policy( { item => $item, patron => $patron } ); > last if $this_item->{allow_onshelf_holds}; > } > >diff --git a/reserve/request.pl b/reserve/request.pl >index d94a8ab6af..760c566de1 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -47,7 +47,7 @@ use Koha::Biblios; > use Koha::DateUtils; > use Koha::Checkouts; > use Koha::Holds; >-use Koha::IssuingRules; >+use Koha::CirculationRules; > use Koha::Items; > use Koha::ItemTypes; > use Koha::Libraries; >@@ -454,7 +454,7 @@ foreach my $biblionumber (@biblionumbers) { > my $can_item_be_reserved = CanItemBeReserved( $patron->borrowernumber, $itemnumber ); > $item->{not_holdable} = $can_item_be_reserved unless ( $can_item_be_reserved eq 'OK' ); > >- $item->{item_level_holds} = Koha::IssuingRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } ); >+ $item->{item_level_holds} = Koha::CirculationRules->get_opacitemholds_policy( { item => $item_object, patron => $patron } ); > > if ( > !$item->{cantreserve} >diff --git a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >index f72a2d9667..d2e1714ced 100755 >--- a/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >+++ b/t/db_dependent/Holds/DisallowHoldIfItemsAvailable.t >@@ -269,20 +269,17 @@ my $hold = $builder->build({ > } > }); > >-$dbh->do("DELETE FROM issuingrules"); >-$rule = Koha::IssuingRule->new( >+Koha::CirculationRules->set_rules( > { >- categorycode => '*', >- itemtype => '*', >- branchcode => '*', >- maxissueqty => 99, >- issuelength => 7, >- lengthunit => 8, >- reservesallowed => 99, >- onshelfholds => 0, >+ categorycode => undef, >+ itemtype => undef, >+ branchcode => undef, >+ rules => { >+ maxissueqty => 99, >+ onshelfholds => 2, >+ } > } > ); >-$rule->store(); > > $is = IsAvailableForItemLevelRequest( $item3, $borrower1); > is( $is, 1, "Item can be held, items in transit are not available" ); >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 44a973757b..c602ba4ee1 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -563,19 +563,6 @@ Koha::CirculationRules->set_rules( > } > ); > >-ok( C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() allowed" ); >-Koha::CirculationRules->set_rules( >- { >- categorycode => $categorycode, >- itemtype => $itype, >- branchcode => $holdingbranch, >- rules => { >- onshelfholds => 0, >- } >- } >-); >-ok( !C4::Reserves::OnShelfHoldsAllowed($item, $borrower), "OnShelfHoldsAllowed() disallowed" ); >- > # tests for MoveReserve in relation to ConfirmFutureHolds (BZ 14526) > # hold from A pos 1, today, no fut holds: MoveReserve should fill it > $dbh->do('DELETE FROM reserves', undef, ($bibnum)); >-- >2.15.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 18936
:
65247
|
65248
|
65249
|
67629
|
67758
|
68236
|
71034
|
71035
|
71036
|
71037
|
71038
|
71039
|
71040
|
71041
|
72230
|
72231
|
72232
|
72233
|
72234
|
72235
|
72236
|
72237
|
72238
|
91953
|
91954
|
91955
|
91956
|
91957
|
91958
|
91959
|
91960
|
91961
|
91962
|
91963
|
91964
|
91965
|
91966
|
91967
|
91968
|
91969
|
91970
|
91971
|
91972
|
91973
|
91974
|
91975
|
94179
|
94180
|
94181
|
94182
|
94183
|
94184
|
94185
|
94186
|
94187
|
94188
|
94189
|
94190
|
94191
|
94192
|
94193
|
94194
|
94195
|
94196
|
94197
|
94198
|
94199
|
94200
|
98299
|
98300
|
98301
|
98302
|
98303
|
98304
|
98305
|
98306
|
98307
|
98308
|
98309
|
98310
|
98311
|
98312
|
98313
|
98314
|
98315
|
98316
|
98317
|
98318
|
98319
|
98320
|
98321
|
98322
|
98323
|
98324
|
98325
|
98326
|
98327
|
98328
|
98329
|
98330
|
98331
|
98332
|
98333
|
98334
|
98335
|
98336
|
98337
|
98338
|
98339
|
98340
|
98341
|
98342
|
98343
|
98344
|
98345
|
98346
|
98347
|
98407
|
98408