Bug 13113 - Prevent juvenile/children from reserving ageRestricted material
There is no reason for underage borrowers to reserve ageRestricted material and then be denied it's check-out due to ageRestriction. This patch prevents reserving material for borrowers not suitably aged. # # # # # # # A PRIORI # # # # # # # BOTH THE STAFF CLIENT AND THE OPAC 1. Find a Record with Items, update the MARC Subfield 521a to "PEGI 16". 2. Get a Borrower who is younger than 16 years. 3. Place a hold for the underage Borrower for the ageRestricted Record. 4. You can reserve an ageRestricted Record with ease. STAFF CLIENT ONLY 5. Check-in an Item from the ageRestricted Record and catch the reservation. 6. Check-out the ageRestricted Item for this underage Borrower. 7. You get a notification about being unable to check-out due to age restriction. How lame is that for a 12 year old? # # # # # # # # # A POSTERIORI # # # # # # # # # STAFF CLIENT 1. Find a Record with Items, update the MARC Subfield 521a to "PEGI 16". 2. Get a Borrower who is younger than 16 years. 3. Check-out an ageRestricted Item for this underage Borrower. 4. You get a notification about having the maximum amount of reserves. 5. Place a hold for the underage Borrower for the ageRestricted Record. 6. You get a notification, that placing a hold on ageRestricted material is forbidden. Includes Unit tests. Followed test plan. Patch behaves as expected. (Note: Propagating error messages to template will be handled in Bug 13116 or 11999) Signed-off-by: Marc Véron <veron@veron.ch> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
This commit is contained in:
parent
ae7d5fd11b
commit
7767f2e53b
|
|
@ -486,12 +486,16 @@ sub CanItemBeReserved{
|
|||
# we retrieve borrowers and items informations #
|
||||
# item->{itype} will come for biblioitems if necessery
|
||||
my $item = GetItem($itemnumber);
|
||||
my $biblioData = C4::Biblio::GetBiblioData( $item->{biblionumber} );
|
||||
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);
|
||||
|
||||
# If an item is damaged and we don't allow holds on damaged items, we can stop right here
|
||||
return 0 if ( $item->{damaged} && !C4::Context->preference('AllowHoldsOnDamagedItems') );
|
||||
|
||||
my $borrower = C4::Members::GetMember('borrowernumber'=>$borrowernumber);
|
||||
|
||||
#Check for the age restriction
|
||||
my ($ageRestriction, $daysToAgeRestriction) = C4::Circulation::GetAgeRestriction( $biblioData->{agerestriction}, $borrower );
|
||||
return 0 if $daysToAgeRestriction && $daysToAgeRestriction > 0;
|
||||
|
||||
my $controlbranch = C4::Context->preference('ReservesControlBranch');
|
||||
my $itemtypefield = C4::Context->preference('item-level_itypes') ? "itype" : "itemtype";
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
use Modern::Perl;
|
||||
|
||||
use Test::More tests => 50;
|
||||
use Test::More tests => 53;
|
||||
|
||||
use MARC::Record;
|
||||
use DateTime::Duration;
|
||||
|
|
@ -471,6 +471,38 @@ is($cancancel, 0, 'Reserve in waiting status cant be canceled');
|
|||
|
||||
# End of tests for bug 12876
|
||||
|
||||
####
|
||||
####### Testing Bug 13113 - Prevent juvenile/children from reserving ageRestricted material >>>
|
||||
####
|
||||
|
||||
C4::Context->set_preference( 'AgeRestrictionMarker', 'FSK|PEGI|Age|K' );
|
||||
|
||||
#Reserving an not-agerestricted Biblio by a Borrower with no dateofbirth is tested previously.
|
||||
|
||||
#Set the ageRestriction for the Biblio
|
||||
my $record = GetMarcBiblio( $bibnum );
|
||||
my ( $ageres_tagid, $ageres_subfieldid ) = GetMarcFromKohaField( "biblioitems.agerestriction", '' );
|
||||
$record->append_fields( MARC::Field->new($ageres_tagid, '', '', $ageres_subfieldid => 'PEGI 16') );
|
||||
C4::Biblio::ModBiblio( $record, $bibnum, '' );
|
||||
|
||||
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving an ageRestricted Biblio without a borrower dateofbirth succeeds" );
|
||||
|
||||
#Set the dateofbirth for the Borrower making him "too young".
|
||||
my $now = DateTime->now();
|
||||
C4::Members::SetAge( $borrower, '0015-00-00' );
|
||||
C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $borrower->{dateofbirth} );
|
||||
|
||||
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 0, "Reserving a 'PEGI 16' Biblio by a 15 year old borrower fails");
|
||||
|
||||
#Set the dateofbirth for the Borrower making him "too old".
|
||||
C4::Members::SetAge( $borrower, '0030-00-00' );
|
||||
C4::Members::ModMember( borrowernumber => $borrowernumber, dateofbirth => $borrower->{dateofbirth} );
|
||||
|
||||
is( C4::Reserves::CanBookBeReserved($borrowernumber, $biblionumber) , 1, "Reserving a 'PEGI 16' Biblio by a 30 year old borrower succeeds");
|
||||
####
|
||||
####### EO Bug 13113 <<<
|
||||
####
|
||||
|
||||
$dbh->rollback;
|
||||
|
||||
sub count_hold_print_messages {
|
||||
|
|
|
|||
Loading…
Reference in New Issue