Bugzilla – Attachment 161812 Details for
Bug 35963
Problem using some filters in the bundled items table
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35963: Fix bundled items table ordering and filtering
Bug-35963-Fix-bundled-items-table-ordering-and-fil.patch (text/plain), 4.13 KB, created by
Julian Maurice
on 2024-02-07 15:02:09 UTC
(
hide
)
Description:
Bug 35963: Fix bundled items table ordering and filtering
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2024-02-07 15:02:09 UTC
Size:
4.13 KB
patch
obsolete
>From 3a909e78af2efe9b5302d4c6b5f4e1cfd7aeda11 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Wed, 7 Feb 2024 14:36:01 +0100 >Subject: [PATCH] Bug 35963: Fix bundled items table ordering and filtering > >Using the many-to-many relationship results in the table alias `me` to >be used for table `item_bundles` instead of the expected table `items`. >This causes ordering and filtering to fail for columns Callnumber and >Barcode. >Using Koha::Items->search does not have this problem. > >This patch also disables ordering by status because it does not work >(error message is: "Cannot find Koha::Object class for return_claim'") > >Test plan: >1. Create an item bundle > https://koha-community.org/manual/23.11/en/html/circulation.html#circulating-bundles >2. Add at least 2 items to this bundle >3. Verify that ordering/filtering by callnumber or barcode works >4. Run `prove t/db_dependent/api/v1/items/bundled_items.t` >--- > Koha/REST/V1/Items.pm | 11 ++++- > .../prog/en/modules/catalogue/detail.tt | 2 +- > t/db_dependent/api/v1/items/bundled_items.t | 48 +++++++++++++++++++ > 3 files changed, 58 insertions(+), 3 deletions(-) > create mode 100644 t/db_dependent/api/v1/items/bundled_items.t > >diff --git a/Koha/REST/V1/Items.pm b/Koha/REST/V1/Items.pm >index 5db12b669d1..69333c1bdf6 100644 >--- a/Koha/REST/V1/Items.pm >+++ b/Koha/REST/V1/Items.pm >@@ -294,8 +294,15 @@ sub bundled_items { > } > > return try { >- my $items_set = $item->bundle_items; >- my $items = $c->objects->search( $items_set ); >+ my $items_set = Koha::Items->search( >+ { >+ 'item_bundles_item.host' => $item_id, >+ }, >+ { >+ join => 'item_bundles_item', >+ } >+ ); >+ my $items = $c->objects->search($items_set); > return $c->render( > status => 200, > openapi => $items >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index 9764f45735d..48f96e6c87f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1907,7 +1907,7 @@ > "data": "lost_status:last_seen_date:return_claim.patron", > "title": _("Status"), > "searchable": false, >- "orderable": true, >+ "orderable": false, > "render": function(data, type, row, meta) { > if ( row.lost_status == bundle_lost_value ) { > let out = '<span class="lost">' + _("Last seen") + ': ' + $date(row.last_seen_date) + '</span>'; >diff --git a/t/db_dependent/api/v1/items/bundled_items.t b/t/db_dependent/api/v1/items/bundled_items.t >new file mode 100644 >index 00000000000..cab4b23e9ab >--- /dev/null >+++ b/t/db_dependent/api/v1/items/bundled_items.t >@@ -0,0 +1,48 @@ >+#!/usr/bin/env perl >+ >+use Modern::Perl; >+ >+use Test::More tests => 1; >+use Test::MockModule; >+use Test::Mojo; >+ >+use t::lib::TestBuilder; >+use t::lib::Mocks; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+t::lib::Mocks::mock_preference( 'RESTBasicAuth', 1 ); >+ >+my $t = Test::Mojo->new('Koha::REST::V1'); >+ >+subtest 'order by me.barcode should return 200' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $bundle = $builder->build_sample_item; >+ my $item = $builder->build_sample_item; >+ $bundle->add_to_bundle($item); >+ >+ my $patron = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { flags => 4 } >+ } >+ ); >+ >+ my $password = 'thePassword123'; >+ >+ $patron->set_password( { password => $password, skip_validation => 1 } ); >+ >+ my $userid = $patron->userid; >+ my $itemnumber = $bundle->itemnumber; >+ >+ $t->get_ok( "//$userid:$password@/api/v1/items/$itemnumber/bundled_items?_order_by=+me.barcode" ) >+ ->status_is(200); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.30.2
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 35963
:
161812
|
162521
|
162522
|
162523
|
162718
|
162719
|
162720