Lines 56-69
sub get {
Link Here
|
56 |
|
56 |
|
57 |
my $biblio = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, $attributes ); |
57 |
my $biblio = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, $attributes ); |
58 |
|
58 |
|
59 |
unless ( $biblio ) { |
59 |
return $c->render_resource_not_found("Bibliographic record") |
60 |
return $c->render( |
60 |
unless $biblio; |
61 |
status => 404, |
|
|
62 |
openapi => { |
63 |
error => "Object not found." |
64 |
} |
65 |
); |
66 |
} |
67 |
|
61 |
|
68 |
return try { |
62 |
return try { |
69 |
|
63 |
|
Lines 128-139
sub delete {
Link Here
|
128 |
|
122 |
|
129 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
123 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
130 |
|
124 |
|
131 |
if ( not defined $biblio ) { |
125 |
return $c->render_resource_not_found("Bibliographic record") |
132 |
return $c->render( |
126 |
unless $biblio; |
133 |
status => 404, |
|
|
134 |
openapi => { error => "Object not found" } |
135 |
); |
136 |
} |
137 |
|
127 |
|
138 |
return try { |
128 |
return try { |
139 |
my $error = DelBiblio( $biblio->id ); |
129 |
my $error = DelBiblio( $biblio->id ); |
Lines 166-179
sub get_public {
Link Here
|
166 |
{ biblionumber => $c->param('biblio_id') }, |
156 |
{ biblionumber => $c->param('biblio_id') }, |
167 |
{ prefetch => ['metadata'] } ); |
157 |
{ prefetch => ['metadata'] } ); |
168 |
|
158 |
|
169 |
unless ($biblio) { |
159 |
return $c->render_resource_not_found("Bibliographic record") |
170 |
return $c->render( |
160 |
unless $biblio; |
171 |
status => 404, |
|
|
172 |
openapi => { |
173 |
error => "Object not found." |
174 |
} |
175 |
); |
176 |
} |
177 |
|
161 |
|
178 |
return try { |
162 |
return try { |
179 |
|
163 |
|
Lines 187-200
sub get_public {
Link Here
|
187 |
# unless there's a logged in user, and there's an exception for it's |
171 |
# unless there's a logged in user, and there's an exception for it's |
188 |
# category |
172 |
# category |
189 |
unless ( $patron and $patron->category->override_hidden_items ) { |
173 |
unless ( $patron and $patron->category->override_hidden_items ) { |
190 |
if ( $biblio->hidden_in_opac({ rules => $opachiddenitems_rules }) ) |
174 |
if ( $biblio->hidden_in_opac( { rules => $opachiddenitems_rules } ) ) { |
191 |
{ |
175 |
return $c->render_resource_not_found("Bibliographic record"); |
192 |
return $c->render( |
|
|
193 |
status => 404, |
194 |
openapi => { |
195 |
error => "Object not found." |
196 |
} |
197 |
); |
198 |
} |
176 |
} |
199 |
} |
177 |
} |
200 |
|
178 |
|
Lines 259-270
sub get_bookings {
Link Here
|
259 |
|
237 |
|
260 |
my $biblio = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['bookings'] } ); |
238 |
my $biblio = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['bookings'] } ); |
261 |
|
239 |
|
262 |
unless ($biblio) { |
240 |
return $c->render_resource_not_found("Bibliographic record") |
263 |
return $c->render( |
241 |
unless $biblio; |
264 |
status => 404, |
|
|
265 |
openapi => { error => "Object not found." } |
266 |
); |
267 |
} |
268 |
|
242 |
|
269 |
return try { |
243 |
return try { |
270 |
|
244 |
|
Lines 291-302
sub get_items {
Link Here
|
291 |
my $biblio = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } ); |
265 |
my $biblio = Koha::Biblios->find( { biblionumber => $c->param('biblio_id') }, { prefetch => ['items'] } ); |
292 |
my $bookable_only = $c->param('bookable'); |
266 |
my $bookable_only = $c->param('bookable'); |
293 |
|
267 |
|
294 |
unless ($biblio) { |
268 |
return $c->render_resource_not_found("Bibliographic record") |
295 |
return $c->render( |
269 |
unless $biblio; |
296 |
status => 404, |
|
|
297 |
openapi => { error => "Object not found." } |
298 |
); |
299 |
} |
300 |
|
270 |
|
301 |
return try { |
271 |
return try { |
302 |
|
272 |
|
Lines 330-341
sub add_item {
Link Here
|
330 |
my $biblio_id = $c->param('biblio_id'); |
300 |
my $biblio_id = $c->param('biblio_id'); |
331 |
my $biblio = Koha::Biblios->find( $biblio_id ); |
301 |
my $biblio = Koha::Biblios->find( $biblio_id ); |
332 |
|
302 |
|
333 |
unless ($biblio) { |
303 |
return $c->render_resource_not_found("Bibliographic record") |
334 |
return $c->render( |
304 |
unless $biblio; |
335 |
status => 404, |
|
|
336 |
openapi => { error => "Biblio not found" } |
337 |
); |
338 |
} |
339 |
|
305 |
|
340 |
my $body = $c->req->json; |
306 |
my $body = $c->req->json; |
341 |
|
307 |
|
Lines 443-463
sub update_item {
Link Here
|
443 |
my $biblio_id = $c->param('biblio_id'); |
409 |
my $biblio_id = $c->param('biblio_id'); |
444 |
my $item_id = $c->param('item_id'); |
410 |
my $item_id = $c->param('item_id'); |
445 |
my $biblio = Koha::Biblios->find( { biblionumber => $biblio_id } ); |
411 |
my $biblio = Koha::Biblios->find( { biblionumber => $biblio_id } ); |
446 |
unless ($biblio) { |
412 |
|
447 |
return $c->render( |
413 |
return $c->render_resource_not_found("Bibliographic record") |
448 |
status => 404, |
414 |
unless $biblio; |
449 |
openapi => { error => "Biblio not found" } |
|
|
450 |
); |
451 |
} |
452 |
|
415 |
|
453 |
my $item = $biblio->items->find({ itemnumber => $item_id }); |
416 |
my $item = $biblio->items->find({ itemnumber => $item_id }); |
454 |
|
417 |
|
455 |
unless ($item) { |
418 |
return $c->render_resource_not_found("Item") |
456 |
return $c->render( |
419 |
unless $item; |
457 |
status => 404, |
|
|
458 |
openapi => { error => "Item not found" } |
459 |
); |
460 |
} |
461 |
|
420 |
|
462 |
my $body = $c->req->json; |
421 |
my $body = $c->req->json; |
463 |
|
422 |
|
Lines 501-512
sub get_checkouts {
Link Here
|
501 |
try { |
460 |
try { |
502 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
461 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
503 |
|
462 |
|
504 |
unless ($biblio) { |
463 |
return $c->render_resource_not_found("Bibliographic record") |
505 |
return $c->render( |
464 |
unless $biblio; |
506 |
status => 404, |
|
|
507 |
openapi => { error => 'Object not found' } |
508 |
); |
509 |
} |
510 |
|
465 |
|
511 |
my $checkouts = |
466 |
my $checkouts = |
512 |
($checked_in) |
467 |
($checked_in) |
Lines 535-546
sub pickup_locations {
Link Here
|
535 |
|
490 |
|
536 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
491 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
537 |
|
492 |
|
538 |
unless ($biblio) { |
493 |
return $c->render_resource_not_found("Bibliographic record") |
539 |
return $c->render( |
494 |
unless $biblio; |
540 |
status => 404, |
|
|
541 |
openapi => { error => "Biblio not found" } |
542 |
); |
543 |
} |
544 |
|
495 |
|
545 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
496 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
546 |
$c->req->params->remove('patron_id'); |
497 |
$c->req->params->remove('patron_id'); |
Lines 604-617
sub get_items_public {
Link Here
|
604 |
{ prefetch => ['items'] } |
555 |
{ prefetch => ['items'] } |
605 |
); |
556 |
); |
606 |
|
557 |
|
607 |
unless ( $biblio ) { |
558 |
return $c->render_resource_not_found("Bibliographic record") |
608 |
return $c->render( |
559 |
unless $biblio; |
609 |
status => 404, |
|
|
610 |
openapi => { |
611 |
error => "Object not found." |
612 |
} |
613 |
); |
614 |
} |
615 |
|
560 |
|
616 |
return try { |
561 |
return try { |
617 |
|
562 |
|
Lines 641-654
sub set_rating {
Link Here
|
641 |
|
586 |
|
642 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
587 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
643 |
|
588 |
|
644 |
unless ($biblio) { |
589 |
$c->render_resource_not_found("Bibliographic record") |
645 |
return $c->render( |
590 |
unless $biblio; |
646 |
status => 404, |
|
|
647 |
openapi => { |
648 |
error => "Object not found." |
649 |
} |
650 |
); |
651 |
} |
652 |
|
591 |
|
653 |
my $patron = $c->stash('koha.user'); |
592 |
my $patron = $c->stash('koha.user'); |
654 |
unless ($patron) { |
593 |
unless ($patron) { |
Lines 775-786
sub update {
Link Here
|
775 |
|
714 |
|
776 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
715 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
777 |
|
716 |
|
778 |
if ( ! defined $biblio ) { |
717 |
$c->render_resource_not_found("Bibliographic record") |
779 |
return $c->render( |
718 |
unless $biblio; |
780 |
status => 404, |
|
|
781 |
openapi => { error => "Object not found" } |
782 |
); |
783 |
} |
784 |
|
719 |
|
785 |
try { |
720 |
try { |
786 |
my $headers = $c->req->headers; |
721 |
my $headers = $c->req->headers; |