Bugzilla – Attachment 150742 Details for
Bug 31799
Add PUT endpoint for Items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31799: (follow-up) Tidy up and fix duplicate barcode handling
Bug-31799-follow-up-Tidy-up-and-fix-duplicate-barc.patch (text/plain), 2.39 KB, created by
Nick Clemens (kidclamp)
on 2023-05-05 12:18:24 UTC
(
hide
)
Description:
Bug 31799: (follow-up) Tidy up and fix duplicate barcode handling
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-05-05 12:18:24 UTC
Size:
2.39 KB
patch
obsolete
>From 2e25c3693400ae4fc97234c3d58e12ad3924c038 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Tue, 3 Jan 2023 16:09:10 -0300 >Subject: [PATCH] Bug 31799: (follow-up) Tidy up and fix duplicate barcode > handling > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > Koha/REST/V1/Biblios.pm | 28 ++++++++-------------------- > t/db_dependent/api/v1/biblios.t | 2 +- > 2 files changed, 9 insertions(+), 21 deletions(-) > >diff --git a/Koha/REST/V1/Biblios.pm b/Koha/REST/V1/Biblios.pm >index 72c37b4fc3..5d2c7ced32 100644 >--- a/Koha/REST/V1/Biblios.pm >+++ b/Koha/REST/V1/Biblios.pm >@@ -432,32 +432,20 @@ sub update_item { > > $item->set_from_api($body); > >- my $barcodeSearch; >- $barcodeSearch = Koha::Items->search( { barcode => $body->{external_id} } ) if defined $body->{external_id}; >- >- if ( $barcodeSearch >- && ($barcodeSearch->count > 1 >- || ($barcodeSearch->count == 1 >- && $barcodeSearch->next->itemnumber != $item->itemnumber >- ) >- ) >- ) >- { >- return $c->render( >- status => 400, >- openapi => { error => "Barcode not unique" } >- ); >- } >- >- my $storedItem = $item->store; >- $storedItem->discard_changes; >+ $item->store->discard_changes; > > $c->render( > status => 200, >- openapi => $storedItem->to_api >+ openapi => $item->to_api > ); > } > catch { >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { >+ return $c->render( >+ status => 409, >+ openapi => { error => 'Duplicate barcode.' } >+ ); >+ } > $c->unhandled_exception($_); > } > } >diff --git a/t/db_dependent/api/v1/biblios.t b/t/db_dependent/api/v1/biblios.t >index 8a73be0b57..17d7dba545 100644 >--- a/t/db_dependent/api/v1/biblios.t >+++ b/t/db_dependent/api/v1/biblios.t >@@ -1772,7 +1772,7 @@ subtest 'update_item() tests' => sub { > $t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { > external_id => $other_item->barcode, > }) >- ->status_is(400, 'Barcode not unique'); >+ ->status_is(409, 'Barcode not unique'); > > $t->put_ok("//$userid:$password@/api/v1/biblios/$biblio_id/items/$item_id" => json => { > replacement_price => 30, >-- >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 31799
:
144902
|
144949
|
144959
|
145632
|
150607
|
150608
|
150609
|
150741
| 150742 |
150743