Bugzilla – Attachment 88301 Details for
Bug 11999
Add two checks in CanBookBeReserved and CanItemBeReserved
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11999: Check for age restriction in CanBookBeReserved
Bug-11999-Check-for-age-restriction-in-CanBookBeRe.patch (text/plain), 4.45 KB, created by
Arthur Suzuki
on 2019-04-18 14:50:48 UTC
(
hide
)
Description:
Bug 11999: Check for age restriction in CanBookBeReserved
Filename:
MIME Type:
Creator:
Arthur Suzuki
Created:
2019-04-18 14:50:48 UTC
Size:
4.45 KB
patch
obsolete
>From 19e5c633a265bfb8d8dbfd2fac4edce74cbc1e1f Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Thu, 23 Apr 2015 11:54:40 +0200 >Subject: [PATCH] Bug 11999: Check for age restriction in CanBookBeReserved > >+ improve t/db_dependent/Reserves.t to make tests pass on UNIMARC >installation > >Maxreserves and alreadyreserved works on ILSDI >Maxreserves works also on staff and opac >Already reserves works also on staff and opac >tests on t/db_dependent/Reserves.t and t/db_dependent/Holds.t passe (using koha_ut db) > >Signed-off-by: Alex Arnaud <alex.arnaud@biblibre.com> >--- > C4/Reserves.pm | 21 +++++++++------------ > t/db_dependent/Reserves.t | 6 +++++- > 2 files changed, 14 insertions(+), 13 deletions(-) > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index be8248c872..9380f0b7bb 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -289,6 +289,12 @@ sub CanBookBeReserved{ > return { status => 'tooManyReserves' }; > } > >+ # Check for the age restriction >+ my $biblioData = C4::Biblio::GetBiblioData( $biblionumber ); >+ my $borrower = $patron->unblessed; >+ my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower ); >+ return { status => 'ageRestricted' } if $daysToAgeRestriction && $daysToAgeRestriction > 0; >+ > my @itemnumbers = Koha::Items->search({ biblionumber => $biblionumber})->get_column("itemnumber"); > > #get items linked via host records >@@ -311,7 +317,6 @@ sub CanBookBeReserved{ > $canReserve = &CanItemBeReserved($borrowernumber, $itemnumber, $branchcode) > if ($canReserve->{status} eq 'OK') { #We can reserve this Item! } > >-<<<<<<< HEAD > @RETURNS { status => OK }, if the Item can be reserved. > { status => ageRestricted }, if the Item is age restricted for this borrower. > { status => damaged }, if the Item is damaged. >@@ -321,15 +326,7 @@ sub CanBookBeReserved{ > { status => libraryNotFound }, if given branchcode is not an existing library > { status => libraryNotPickupLocation }, if given branchcode is not configured to be a pickup location > { status => cannotBeTransferred }, if branch transfer limit applies on given item and branchcode >-======= >-@RETURNS OK, if the Item can be reserved. >- ageRestricted, if the Item is age restricted for this borrower. >- damaged, if the Item is damaged. >- cannotReserveFromOtherBranches, if syspref 'canreservefromotherbranches' is OK. >- tooManyReserves, if the borrower has exceeded his maximum reserve amount. >- notReservable, if holds on this item are not allowed >- alreadyReserved, if the borrower has already reserved this item. >->>>>>>> Bug 11999: Add two checks in CanBookBeReserved and CanItemBeReserved >+ { status => alreadyReserved }, if the borrower has already reserved this item. > > =cut > >@@ -369,14 +366,14 @@ sub CanItemBeReserved { > if ( $hold->itemnumber == $itemnumber > or $hold->biblionumber == $item->{biblionumber} ) > { >- return 'alreadyReserved'; >+ return { status => 'alreadyReserved' }; > } > } > > # Check if borrower has reached the maximum number of holds allowed > my $maxreserves = C4::Context->preference('maxreserves'); > if ($maxreserves && $holds->count >= $maxreserves) { >- return 'tooManyReserves'; >+ return { status => 'tooManyReserves' }; > } > > my $controlbranch = C4::Context->preference('ReservesControlBranch'); >diff --git a/t/db_dependent/Reserves.t b/t/db_dependent/Reserves.t >index 214f42250d..1d0d4265fd 100755 >--- a/t/db_dependent/Reserves.t >+++ b/t/db_dependent/Reserves.t >@@ -59,7 +59,11 @@ my $frameworkcode = q//; > t::lib::Mocks::mock_preference('ReservesNeedReturns', 1); > > # Somewhat arbitrary field chosen for age restriction unit tests. Must be added to db before the framework is cached >-$dbh->do("update marc_subfield_structure set kohafield='biblioitems.agerestriction' where tagfield='521' and tagsubfield='a' and frameworkcode=?", undef, $frameworkcode); >+$dbh->do(q| >+ INSERT INTO marc_subfield_structure (frameworkcode, tagfield, tagsubfield, kohafield) >+ VALUES ('', '521', 'a', 'biblioitems.agerestriction') >+ ON DUPLICATE KEY UPDATE kohafield = VALUES(kohafield) >+|); > my $cache = Koha::Caches->get_instance; > $cache->clear_from_cache("MarcStructure-0-$frameworkcode"); > $cache->clear_from_cache("MarcStructure-1-$frameworkcode"); >-- >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 11999
:
26589
|
28986
|
31524
|
35697
|
36358
|
36404
|
36630
|
38397
|
41951
|
41952
|
44631
|
44632
|
46262
|
46263
|
50224
|
50225
|
58741
|
58742
|
58743
|
63593
|
63594
|
63595
|
66267
|
66268
|
66269
|
66270
|
88300
|
88301
|
88302
|
88303
|
90142
|
90143
|
90144
|
90146
|
90147
|
91046
|
91402
|
91403
|
91479
|
91481
|
91494
|
91580
|
91581
|
91582
|
91590
|
91591
|
91592
|
91593
|
99927
|
99928
|
106481
|
106494
|
111687
|
111688
|
111689
|
112871
|
112872
|
112873
|
112874
|
120776
|
120777
|
120778
|
120779
|
120780
|
121531
|
121612