Bugzilla – Attachment 181536 Details for
Bug 39600
Use the API to render the OPAC ILL requests table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39600: Add Koha::Patron->ill_requests() accessor
Bug-39600-Add-KohaPatron-illrequests-accessor.patch (text/plain), 3.33 KB, created by
Martin Renvoize (ashimema)
on 2025-04-25 14:52:33 UTC
(
hide
)
Description:
Bug 39600: Add Koha::Patron->ill_requests() accessor
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-04-25 14:52:33 UTC
Size:
3.33 KB
patch
obsolete
>From 14c4ba095a1940ab33a72d44cbd9ec1ba76a049e Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 23 Apr 2025 12:08:55 -0300 >Subject: [PATCH] Bug 39600: Add Koha::Patron->ill_requests() accessor >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Tadeusz âtadzikâ SoÅnierz <tadeusz@sosnierz.com> >Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> >--- > Koha/Patron.pm | 14 ++++++++++++++ > Koha/Schema/Result/Borrower.pm | 7 +++++++ > t/db_dependent/Koha/Patron.t | 24 +++++++++++++++++++++++- > 3 files changed, 44 insertions(+), 1 deletion(-) > >diff --git a/Koha/Patron.pm b/Koha/Patron.pm >index e7a35e57f11..56df7f9b8da 100644 >--- a/Koha/Patron.pm >+++ b/Koha/Patron.pm >@@ -46,6 +46,7 @@ use Koha::Encryption; > use Koha::Exceptions; > use Koha::Exceptions::Password; > use Koha::Holds; >+use Koha::ILL::Requests; > use Koha::Old::Checkouts; > use Koha::OverdueRules; > use Koha::Patron::Attributes; >@@ -1481,6 +1482,19 @@ sub checkouts { > return Koha::Checkouts->_new_from_dbic($checkouts); > } > >+=head3 ill_requests >+ >+ my $ill_requests = $patron->ill_requests(); >+ >+Method that returns the related I<Koha::ILL::Requests> iterator. >+ >+=cut >+ >+sub ill_requests { >+ my ($self) = @_; >+ return Koha::ILL::Requests->_new_from_dbic( scalar $self->_result->ill_requests ); >+} >+ > =head3 pending_checkouts > > my $pending_checkouts = $patron->pending_checkouts >diff --git a/Koha/Schema/Result/Borrower.pm b/Koha/Schema/Result/Borrower.pm >index 5621f628c9d..a24aaca0ba5 100644 >--- a/Koha/Schema/Result/Borrower.pm >+++ b/Koha/Schema/Result/Borrower.pm >@@ -2230,6 +2230,13 @@ __PACKAGE__->add_columns( > '+protected' => { is_boolean => 1 }, > ); > >+__PACKAGE__->has_many( >+ "ill_requests", >+ "Koha::Schema::Result::Illrequest", >+ { "foreign.borrowernumber" => "self.borrowernumber" }, >+ { cascade_copy => 0, cascade_delete => 0 }, >+); >+ > =head2 koha_objects_class > > Missing POD for koha_objects_class. >diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t >index 5197e53468f..dc2ed4dca07 100755 >--- a/t/db_dependent/Koha/Patron.t >+++ b/t/db_dependent/Koha/Patron.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 38; >+use Test::More tests => 39; > use Test::Exception; > use Test::Warn; > use Time::Fake; >@@ -2846,3 +2846,25 @@ subtest 'preferred_name' => sub { > is( $patron->preferred_name, "Preferred again", "Preferred name set on update when passed" ); > > }; >+ >+subtest 'ill_requests() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); >+ >+ my $reqs_rs = $patron->ill_requests(); >+ is( ref($reqs_rs), 'Koha::ILL::Requests', 'Returned object type is correct' ); >+ is( $reqs_rs->count, 0, 'No linked ILL requests for the patron' ); >+ >+ # add two requests >+ $builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } ); >+ $builder->build_object( { class => 'Koha::ILL::Requests', value => { borrowernumber => $patron->id } } ); >+ >+ $reqs_rs = $patron->ill_requests(); >+ is( $reqs_rs->count, 2, 'Two linked ILL requests for the patron' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.49.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 39600
:
180758
|
180759
|
180760
|
180761
|
180762
|
180763
|
180764
|
180778
|
180781
|
180785
|
180786
|
180787
|
180821
|
181132
|
181133
|
181134
|
181135
|
181437
|
181438
|
181439
|
181440
|
181441
|
181442
|
181443
|
181524
|
181525
|
181526
|
181532
|
181533
|
181534
|
181535
| 181536 |
181537
|
181538
|
181608
|
181652