View | Details | Raw Unified | Return to bug 39336
Collapse All | Expand All

(-)a/Koha/REST/V1/Biblios.pm (+5 lines)
Lines 161-166 sub get_public { Link Here
161
        my $schema = $biblio->metadata->schema // C4::Context->preference("marcflavour");
161
        my $schema = $biblio->metadata->schema // C4::Context->preference("marcflavour");
162
        my $patron = $c->stash('koha.user');
162
        my $patron = $c->stash('koha.user');
163
163
164
        # Check if the bibliographic record is suppressed in OPAC
165
        if ( C4::Context->preference('OpacSuppression') && $biblio->opac_suppressed ) {
166
            return $c->render_resource_not_found("Bibliographic record");
167
        }
168
164
        # Check if the bibliographic record should be hidden for unprivileged access
169
        # Check if the bibliographic record should be hidden for unprivileged access
165
        # unless there's a logged in user, and there's an exception for it's category
170
        # unless there's a logged in user, and there's an exception for it's category
166
        my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems');
171
        my $opachiddenitems_rules = C4::Context->yaml_preference('OpacHiddenItems');
(-)a/t/db_dependent/api/v1/biblios.t (-2 / +29 lines)
Lines 292-298 subtest 'delete() tests' => sub { Link Here
292
292
293
subtest 'get_public() tests' => sub {
293
subtest 'get_public() tests' => sub {
294
294
295
    plan tests => 25;
295
    plan tests => 26;
296
296
297
    $schema->storage->txn_begin;
297
    $schema->storage->txn_begin;
298
298
Lines 425-430 subtest 'get_public() tests' => sub { Link Here
425
        t::lib::Mocks::mock_preference('OpacHiddenItems');
425
        t::lib::Mocks::mock_preference('OpacHiddenItems');
426
    };
426
    };
427
427
428
    subtest 'OpacSuppression tests' => sub {
429
430
        plan tests => 8;
431
432
        # Test with OpacSuppression enabled and biblio suppressed
433
        t::lib::Mocks::mock_preference( 'OpacSuppression', 1 );
434
        $biblio->set( { opac_suppressed => 1 } )->store;
435
436
        $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
437
            ->status_is( 404, 'OpacSuppression enabled + opac_suppressed => hidden' );
438
439
        # Test with OpacSuppression enabled but biblio not suppressed
440
        $biblio->set( { opac_suppressed => 0 } )->store;
441
        $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
442
            ->status_is( 200, 'OpacSuppression enabled + not suppressed => displayed' );
443
444
        # Test with OpacSuppression disabled but biblio suppressed
445
        t::lib::Mocks::mock_preference( 'OpacSuppression', 0 );
446
        $biblio->set( { opac_suppressed => 1 } )->store;
447
        $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
448
            ->status_is( 200, 'OpacSuppression disabled + opac_suppressed => displayed' );
449
450
        # Test with both disabled
451
        $biblio->set( { opac_suppressed => 0 } )->store;
452
        $t->get_ok( "/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'text/plain' } )
453
            ->status_is( 200, 'OpacSuppression disabled + not suppressed => displayed' );
454
    };
455
428
    $biblio->delete;
456
    $biblio->delete;
429
    $t->get_ok(
457
    $t->get_ok(
430
        "//$userid:$password@/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } )
458
        "//$userid:$password@/api/v1/public/biblios/" . $biblio->biblionumber => { Accept => 'application/marc' } )
431
- 

Return to bug 39336