Bugzilla – Attachment 189522 Details for
Bug 40841
Limit z39.50 targets to specific branches
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40841: Add Z39.50 library limits
Bug-40841-Add-Z3950-library-limits.patch (text/plain), 4.52 KB, created by
David Nind
on 2025-11-12 19:28:02 UTC
(
hide
)
Description:
Bug 40841: Add Z39.50 library limits
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-11-12 19:28:02 UTC
Size:
4.52 KB
patch
obsolete
>From ca4865ca44d3b653252d04e94b9281fb0bd4682e Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tom=C3=A1s=20Cohen=20Arazi?= <tomascohen@theke.io> >Date: Wed, 29 Oct 2025 09:36:13 -0300 >Subject: [PATCH] Bug 40841: Add Z39.50 library limits >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds the library limits mixin to the Z39.50 classes following >a well established pattern in Koha. > >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >Signed-off-by: David Nind <david@davidnind.com> >--- > Koha/Z3950Server.pm | 16 +++++++- > Koha/Z3950Servers.pm | 2 +- > t/db_dependent/Koha/Z3950Servers.t | 65 +++++++++++++++++++++++++++++- > 3 files changed, 79 insertions(+), 4 deletions(-) > >diff --git a/Koha/Z3950Server.pm b/Koha/Z3950Server.pm >index f4296e30e4..7c80c7a4bb 100644 >--- a/Koha/Z3950Server.pm >+++ b/Koha/Z3950Server.pm >@@ -19,7 +19,7 @@ use Modern::Perl; > > use Koha::Database; > >-use base qw(Koha::Object); >+use base qw(Koha::Object Koha::Object::Limit::Library); > > =head1 NAME > >@@ -27,10 +27,22 @@ Koha::Z3950Server - Koha Z3950Server Object class > > =head1 API > >-=head2 Class Methods >+=head2 Internal methods >+ >+=head3 _library_limits >+ >+Configure library limits for Z39.50 servers > > =cut > >+sub _library_limits { >+ return { >+ class => "Z3950serversBranch", >+ id => "server_id", >+ library => "branchcode", >+ }; >+} >+ > =head3 _type > > Return type of Object relating to Schema ResultSet >diff --git a/Koha/Z3950Servers.pm b/Koha/Z3950Servers.pm >index 1cab680013..968c7efcd1 100644 >--- a/Koha/Z3950Servers.pm >+++ b/Koha/Z3950Servers.pm >@@ -21,7 +21,7 @@ use Koha::Database; > > use Koha::Z3950Server; > >-use base qw(Koha::Objects); >+use base qw(Koha::Objects Koha::Objects::Limit::Library); > > =head1 NAME > >diff --git a/t/db_dependent/Koha/Z3950Servers.t b/t/db_dependent/Koha/Z3950Servers.t >index 6ae9f91fb1..66f1ef8a88 100755 >--- a/t/db_dependent/Koha/Z3950Servers.t >+++ b/t/db_dependent/Koha/Z3950Servers.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > use Test::NoWarnings; >-use Test::More tests => 3; >+use Test::More tests => 4; > use Test::Exception; > > use t::lib::TestBuilder; >@@ -105,3 +105,66 @@ subtest 'Host, syntax and encoding are NOT NULL now (BZ 30571)' => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'library_limits' => sub { >+ plan tests => 8; >+ >+ $schema->storage->txn_begin; >+ >+ my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); >+ >+ my $server = $builder->build_object( >+ { >+ class => 'Koha::Z3950Servers', >+ value => { >+ host => 'test.example.com', >+ port => 210, >+ db => 'testdb' >+ } >+ } >+ ); >+ >+ # Test adding library limit >+ $server->add_library_limit( $library1->branchcode ); >+ my $limits = $server->library_limits(); >+ is( $limits->count, 1, 'One library limit added' ); >+ is( $limits->next->branchcode, $library1->branchcode, 'Correct library limit' ); >+ >+ # Test search with library limits >+ my $servers = Koha::Z3950Servers->search_with_library_limits( >+ { id => $server->id }, >+ {}, >+ $library1->branchcode >+ ); >+ is( $servers->count, 1, 'Server found for authorized library' ); >+ >+ $servers = Koha::Z3950Servers->search_with_library_limits( >+ { id => $server->id }, >+ {}, >+ $library2->branchcode >+ ); >+ is( $servers->count, 0, 'Server not found for unauthorized library' ); >+ >+ # Test replacing library limits >+ $server->library_limits( [ $library1->branchcode, $library2->branchcode ] ); >+ $limits = $server->library_limits(); >+ is( $limits->count, 2, 'Two library limits set' ); >+ >+ # Test removing library limit >+ $server->del_library_limit( $library1->branchcode ); >+ $limits = $server->library_limits(); >+ is( $limits->count, 1, 'One library limit remains' ); >+ is( $limits->next->branchcode, $library2->branchcode, 'Correct remaining limit' ); >+ >+ # Test server with no limits (available to all) >+ my $unrestricted_server = $builder->build_object( { class => 'Koha::Z3950Servers' } ); >+ $servers = Koha::Z3950Servers->search_with_library_limits( >+ { id => $unrestricted_server->id }, >+ {}, >+ $library1->branchcode >+ ); >+ is( $servers->count, 1, 'Unrestricted server available to all libraries' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.39.5
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 40841
:
188587
|
188588
|
188589
|
188590
|
188591
|
188597
|
188598
|
188599
|
188600
|
188601
|
188602
|
188603
|
188604
|
188605
|
188606
|
189497
|
189498
|
189499
|
189500
|
189501
|
189521
| 189522 |
189523
|
189524
|
189525