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->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->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->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->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->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->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 325-336
sub add_item {
Link Here
|
325 |
my $biblio_id = $c->param('biblio_id'); |
295 |
my $biblio_id = $c->param('biblio_id'); |
326 |
my $biblio = Koha::Biblios->find( $biblio_id ); |
296 |
my $biblio = Koha::Biblios->find( $biblio_id ); |
327 |
|
297 |
|
328 |
unless ($biblio) { |
298 |
return $c->resource_not_found("Bibliographic record") |
329 |
return $c->render( |
299 |
unless $biblio; |
330 |
status => 404, |
|
|
331 |
openapi => { error => "Biblio not found" } |
332 |
); |
333 |
} |
334 |
|
300 |
|
335 |
my $body = $c->req->json; |
301 |
my $body = $c->req->json; |
336 |
|
302 |
|
Lines 438-458
sub update_item {
Link Here
|
438 |
my $biblio_id = $c->param('biblio_id'); |
404 |
my $biblio_id = $c->param('biblio_id'); |
439 |
my $item_id = $c->param('item_id'); |
405 |
my $item_id = $c->param('item_id'); |
440 |
my $biblio = Koha::Biblios->find( { biblionumber => $biblio_id } ); |
406 |
my $biblio = Koha::Biblios->find( { biblionumber => $biblio_id } ); |
441 |
unless ($biblio) { |
407 |
|
442 |
return $c->render( |
408 |
return $c->resource_not_found("Bibliographic record") |
443 |
status => 404, |
409 |
unless $biblio; |
444 |
openapi => { error => "Biblio not found" } |
|
|
445 |
); |
446 |
} |
447 |
|
410 |
|
448 |
my $item = $biblio->items->find({ itemnumber => $item_id }); |
411 |
my $item = $biblio->items->find({ itemnumber => $item_id }); |
449 |
|
412 |
|
450 |
unless ($item) { |
413 |
return $c->resource_not_found("Item") |
451 |
return $c->render( |
414 |
unless $item; |
452 |
status => 404, |
|
|
453 |
openapi => { error => "Item not found" } |
454 |
); |
455 |
} |
456 |
|
415 |
|
457 |
my $body = $c->req->json; |
416 |
my $body = $c->req->json; |
458 |
|
417 |
|
Lines 496-507
sub get_checkouts {
Link Here
|
496 |
try { |
455 |
try { |
497 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
456 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
498 |
|
457 |
|
499 |
unless ($biblio) { |
458 |
return $c->resource_not_found("Bibliographic record") |
500 |
return $c->render( |
459 |
unless $biblio; |
501 |
status => 404, |
|
|
502 |
openapi => { error => 'Object not found' } |
503 |
); |
504 |
} |
505 |
|
460 |
|
506 |
my $checkouts = |
461 |
my $checkouts = |
507 |
($checked_in) |
462 |
($checked_in) |
Lines 530-541
sub pickup_locations {
Link Here
|
530 |
|
485 |
|
531 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
486 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
532 |
|
487 |
|
533 |
unless ($biblio) { |
488 |
return $c->resource_not_found("Bibliographic record") |
534 |
return $c->render( |
489 |
unless $biblio; |
535 |
status => 404, |
|
|
536 |
openapi => { error => "Biblio not found" } |
537 |
); |
538 |
} |
539 |
|
490 |
|
540 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
491 |
my $patron = Koha::Patrons->find( $c->param('patron_id') ); |
541 |
$c->req->params->remove('patron_id'); |
492 |
$c->req->params->remove('patron_id'); |
Lines 599-612
sub get_items_public {
Link Here
|
599 |
{ prefetch => ['items'] } |
550 |
{ prefetch => ['items'] } |
600 |
); |
551 |
); |
601 |
|
552 |
|
602 |
unless ( $biblio ) { |
553 |
return $c->resource_not_found("Bibliographic record") |
603 |
return $c->render( |
554 |
unless $biblio; |
604 |
status => 404, |
|
|
605 |
openapi => { |
606 |
error => "Object not found." |
607 |
} |
608 |
); |
609 |
} |
610 |
|
555 |
|
611 |
return try { |
556 |
return try { |
612 |
|
557 |
|
Lines 636-649
sub set_rating {
Link Here
|
636 |
|
581 |
|
637 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
582 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
638 |
|
583 |
|
639 |
unless ($biblio) { |
584 |
$c->resource_not_found("Bibliographic record") |
640 |
return $c->render( |
585 |
unless $biblio; |
641 |
status => 404, |
|
|
642 |
openapi => { |
643 |
error => "Object not found." |
644 |
} |
645 |
); |
646 |
} |
647 |
|
586 |
|
648 |
my $patron = $c->stash('koha.user'); |
587 |
my $patron = $c->stash('koha.user'); |
649 |
unless ($patron) { |
588 |
unless ($patron) { |
Lines 770-781
sub update {
Link Here
|
770 |
|
709 |
|
771 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
710 |
my $biblio = Koha::Biblios->find( $c->param('biblio_id') ); |
772 |
|
711 |
|
773 |
if ( ! defined $biblio ) { |
712 |
$c->resource_not_found("Bibliographic record") |
774 |
return $c->render( |
713 |
unless $biblio; |
775 |
status => 404, |
|
|
776 |
openapi => { error => "Object not found" } |
777 |
); |
778 |
} |
779 |
|
714 |
|
780 |
try { |
715 |
try { |
781 |
my $headers = $c->req->headers; |
716 |
my $headers = $c->req->headers; |