Bugzilla – Attachment 181135 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: Cleanup the changes -- tidy, document, add a missing TT filter
Bug-39600-Cleanup-the-changes----tidy-document-add.patch (text/plain), 7.08 KB, created by
Tomás Cohen Arazi (tcohen)
on 2025-04-17 19:11:51 UTC
(
hide
)
Description:
Bug 39600: Cleanup the changes -- tidy, document, add a missing TT filter
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2025-04-17 19:11:51 UTC
Size:
7.08 KB
patch
obsolete
>From d9480c6f28e537eb61002ce4eea84ec42ae58d2c Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Tadeusz=20=E2=80=9Etadzik=E2=80=9D=20So=C5=9Bnierz?= > <tadeusz@sosnierz.com> >Date: Fri, 11 Apr 2025 11:17:47 +0200 >Subject: [PATCH] Bug 39600: Cleanup the changes -- tidy, document, add a > missing TT filter > >Sponsored-by: Wiko (https://www.wiko-berlin.de/) >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/ILL/Request.pm | 8 ++++--- > Koha/ILL/Request/Attribute.pm | 6 +++++ > Koha/REST/V1/ILL/Requests.pm | 22 +++++++++++++------ > .../bootstrap/en/modules/opac-illrequests.tt | 5 ++--- > opac/opac-illrequests.pl | 1 + > t/db_dependent/api/v1/ill_requests.t | 21 +++++++++++------- > 6 files changed, 42 insertions(+), 21 deletions(-) > >diff --git a/Koha/ILL/Request.pm b/Koha/ILL/Request.pm >index 14f5218c52d..d89e91bda72 100644 >--- a/Koha/ILL/Request.pm >+++ b/Koha/ILL/Request.pm >@@ -2146,9 +2146,11 @@ This method returns the list of publicly readable database fields for both API a > =cut > > sub public_read_list { >- return [qw( >- illrequest_id backend status extended_attributes placed updated >- )]; >+ return [ >+ qw( >+ illrequest_id backend status extended_attributes placed updated >+ ) >+ ]; > } > > =head2 Internal methods >diff --git a/Koha/ILL/Request/Attribute.pm b/Koha/ILL/Request/Attribute.pm >index 3f1bc4e8c87..b36ae2f1c41 100644 >--- a/Koha/ILL/Request/Attribute.pm >+++ b/Koha/ILL/Request/Attribute.pm >@@ -58,6 +58,12 @@ sub request { > return Koha::ILL::Request->_new_from_dbic( $self->_result->illrequest ); > } > >+=head3 public_read_list >+ >+This method returns the list of publicly readable database fields for both API and UI output purposes >+ >+=cut >+ > sub public_read_list { > return [qw(backend illrequest_id readonly type value)]; > } >diff --git a/Koha/REST/V1/ILL/Requests.pm b/Koha/REST/V1/ILL/Requests.pm >index 55c4e59d6fd..bb8eecb15e1 100644 >--- a/Koha/REST/V1/ILL/Requests.pm >+++ b/Koha/REST/V1/ILL/Requests.pm >@@ -58,22 +58,30 @@ sub list { > }; > } > >+=head3 patron_list >+ >+Controller function that handles listing Koha::ILL::Request objects for a given patron. >+ >+The patron must match the requesting user unless the requesting user is a superlibrarian. >+ >+This is a public route, so some request details are omitted. >+ >+=cut >+ > sub patron_list { >- my $c = shift->openapi->valid_input or return; >+ my $c = shift->openapi->valid_input or return; > my $user = $c->stash('koha.user'); >- $c->stash(is_public => 1); >+ $c->stash( is_public => 1 ); > >- if ($user->borrowernumber != $c->param('patron_id') and !$user->is_superlibrarian) { >+ if ( $user->borrowernumber != $c->param('patron_id') and !$user->is_superlibrarian ) { > return $c->render( >- status => 403, >+ status => 403, > openapi => { error => "Cannot lookup ILL requests for other users" } > ); > } > > return try { >- my $reqs = $c->objects->search(Koha::ILL::Requests->search( >- { borrowernumber => $c->param('patron_id') } >- )); >+ my $reqs = $c->objects->search( Koha::ILL::Requests->search( { borrowernumber => $c->param('patron_id') } ) ); > > return $c->render( > status => 200, >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >index b0a355885d1..934ef854bdc 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >@@ -151,8 +151,7 @@ > <th></th> > </tr> > </thead> >- <tbody> >- </tbody> >+ <tbody> </tbody> > </table> > [% ELSIF op == 'view' %] > <h1>View interlibrary loan request</h1> >@@ -487,7 +486,7 @@ > "serverSide": true, > "ajax": { > "cache": true, >- "url": '/api/v1/patrons/[% logged_in_user.borrowernumber %]/ill/requests', >+ "url": '/api/v1/patrons/[% logged_in_user.borrowernumber | html %]/ill/requests', > 'beforeSend': function (xhr, settings) { > this._xhr = xhr; > xhr.setRequestHeader('x-koha-embed', '+strings,extended_attributes'); >diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl >index 27bac82b7ed..27b853a64f4 100755 >--- a/opac/opac-illrequests.pl >+++ b/opac/opac-illrequests.pl >@@ -100,6 +100,7 @@ if ( $op eq 'list' ) { > $template->param( request => $request ); > } elsif ( $op eq 'cud-update' ) { > $request->notesopac( $params->{notesopac} )->store; >+ > # Send a notice to staff alerting them of the update > $request->send_staff_notice('ILL_REQUEST_MODIFIED'); > print $query->redirect( >diff --git a/t/db_dependent/api/v1/ill_requests.t b/t/db_dependent/api/v1/ill_requests.t >index 830a2def2b2..2015d8b0453 100755 >--- a/t/db_dependent/api/v1/ill_requests.t >+++ b/t/db_dependent/api/v1/ill_requests.t >@@ -310,10 +310,12 @@ subtest 'patron_list() tests' => sub { > my $observer_number = $observer->borrowernumber; > > # No requests yet, expect empty for both >- $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( [] ); >- $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)->json_is( [] ); >+ $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200) >+ ->json_is( [] ); >+ $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200) >+ ->json_is( [] ); > >- for (0..25) { >+ for ( 0 .. 25 ) { > $builder->build_object( > { > class => 'Koha::ILL::Requests', >@@ -329,17 +331,20 @@ subtest 'patron_list() tests' => sub { > } > > # Other user should not see anything >- $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200)->json_is( [] ); >+ $t->get_ok("//$observer_userid:$password@/api/v1/patrons/$observer_number/ill/requests")->status_is(200) >+ ->json_is( [] ); > > # Staff notes hidden in the public API >- $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( >+ $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200) >+ ->json_is( > '/0/staff_notes' => undef, >- ); >+ ); > > # Not all requests get returned, pagination works >- $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200)->json_is( >+ $t->get_ok("//$requester_userid:$password@/api/v1/patrons/$requester_number/ill/requests")->status_is(200) >+ ->json_is( > '/21' => undef, >- ); >+ ); > > $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