Bug 39336: Public Biblio endpoint should honour OpacSuppression syspref
This patch makes the Public Biblio endpoint respect the OpacSuppression
system preference and the biblio.opac_suppressed field introduced in
Bug 38330.
When OpacSuppression is enabled and a biblio has opac_suppressed set to 1,
the endpoint now returns a 404 (Not Found) response instead of exposing
the bibliographic record.
Test plan:
1. Apply patch
2. Run: prove t/db_dependent/api/v1/biblios.t
3. Verify all tests pass, including the new OpacSuppression subtest
4. Test manually:
- Enable OpacSuppression syspref
- Set a biblio's opac_suppressed field to 1
- Access /api/v1/public/biblios/{biblio_id}
- Confirm it returns 404
- Set opac_suppressed to 0
- Confirm it returns 200 with the record
- Disable OpacSuppression syspref
- Confirm record is visible regardless of opac_suppressed value
Signed-off-by: David Cook <dcook@prosentient.com.au>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit 05aa74e921)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
parent
f49ca990f8
commit
15adc62abb
|
|
@ -161,6 +161,11 @@ sub get_public {
|
|||
my $schema = $biblio->metadata->schema // C4::Context->preference("marcflavour");
|
||||
my $patron = $c->stash('koha.user');
|
||||
|
||||
# Check if the bibliographic record is suppressed in OPAC
|
||||
if ( C4::Context->preference('OpacSuppression') && $biblio->opac_suppressed ) {
|
||||
return $c->render_resource_not_found("Bibliographic record");
|
||||
}
|
||||
|
||||
# Check if the bibliographic record should be hidden for unprivileged access
|
||||
# unless there's a logged in user, and there's an exception for it's category
|
||||
my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems');
|
||||
|
|
|
|||
|
|
@ -292,7 +292,7 @@ subtest 'delete() tests' => sub {
|
|||
|
||||
subtest 'get_public() tests' => sub {
|
||||
|
||||
plan tests => 25;
|
||||
plan tests => 26;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -425,6 +425,34 @@ subtest 'get_public() tests' => sub {
|
|||
t::lib::Mocks::mock_preference('OpacHiddenItems');
|
||||
};
|
||||
|
||||
subtest 'OpacSuppression tests' => sub {
|
||||
|
||||
plan tests => 8;
|
||||
|
||||
# Test with OpacSuppression enabled and biblio suppressed
|
||||
t::lib::Mocks::mock_preference( 'OpacSuppression', 1 );
|
||||
$biblio->set( { opac_suppressed => 1 } )->store;
|
||||
|
||||
$t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
|
||||
->status_is( 404, 'OpacSuppression enabled + opac_suppressed => hidden' );
|
||||
|
||||
# Test with OpacSuppression enabled but biblio not suppressed
|
||||
$biblio->set( { opac_suppressed => 0 } )->store;
|
||||
$t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
|
||||
->status_is( 200, 'OpacSuppression enabled + not suppressed => displayed' );
|
||||
|
||||
# Test with OpacSuppression disabled but biblio suppressed
|
||||
t::lib::Mocks::mock_preference( 'OpacSuppression', 0 );
|
||||
$biblio->set( { opac_suppressed => 1 } )->store;
|
||||
$t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
|
||||
->status_is( 200, 'OpacSuppression disabled + opac_suppressed => displayed' );
|
||||
|
||||
# Test with both disabled
|
||||
$biblio->set( { opac_suppressed => 0 } )->store;
|
||||
$t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
|
||||
->status_is( 200, 'OpacSuppression disabled + not suppressed => displayed' );
|
||||
};
|
||||
|
||||
$biblio->delete;
|
||||
$t->get_ok(
|
||||
"//$userid:$password@/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } )
|
||||
|
|
|
|||
Loading…
Reference in New Issue