View | Details | Raw Unified | Return to bug 30708
Collapse All | Expand All

(-)a/Koha/REST/V1/Preservation/Processings.pm (-5 / +5 lines)
Lines 54-60 sub get { Link Here
54
    my $c = shift->openapi->valid_input or return;
54
    my $c = shift->openapi->valid_input or return;
55
55
56
    return try {
56
    return try {
57
        my $processing_id = $c->validation->param('processing_id');
57
        my $processing_id = $c->param('processing_id');
58
        my $processing    = $c->objects->find( Koha::Preservation::Processings->search, $processing_id );
58
        my $processing    = $c->objects->find( Koha::Preservation::Processings->search, $processing_id );
59
59
60
        unless ($processing) {
60
        unless ($processing) {
Lines 87-93 sub add { Link Here
87
        Koha::Database->new->schema->txn_do(
87
        Koha::Database->new->schema->txn_do(
88
            sub {
88
            sub {
89
89
90
                my $body = $c->validation->param('body');
90
                my $body = $c->req->json;
91
91
92
                my $attributes = delete $body->{attributes} // [];
92
                my $attributes = delete $body->{attributes} // [];
93
93
Lines 154-160 Controller function that handles updating a Koha::Preservation::Processing objec Link Here
154
sub update {
154
sub update {
155
    my $c = shift->openapi->valid_input or return;
155
    my $c = shift->openapi->valid_input or return;
156
156
157
    my $processing_id = $c->validation->param('processing_id');
157
    my $processing_id = $c->param('processing_id');
158
    my $processing = Koha::Preservation::Processings->find( $processing_id );
158
    my $processing = Koha::Preservation::Processings->find( $processing_id );
159
159
160
    unless ($processing) {
160
    unless ($processing) {
Lines 168-174 sub update { Link Here
168
        Koha::Database->new->schema->txn_do(
168
        Koha::Database->new->schema->txn_do(
169
            sub {
169
            sub {
170
170
171
                my $body = $c->validation->param('body');
171
                my $body = $c->req->json;
172
172
173
                my $attributes = delete $body->{attributes} // [];
173
                my $attributes = delete $body->{attributes} // [];
174
174
Lines 227-233 sub update { Link Here
227
sub delete {
227
sub delete {
228
    my $c = shift->openapi->valid_input or return;
228
    my $c = shift->openapi->valid_input or return;
229
229
230
    my $processing_id = $c->validation->param('processing_id');
230
    my $processing_id = $c->param('processing_id');
231
    my $processing = Koha::Preservation::Processings->find( $processing_id );
231
    my $processing = Koha::Preservation::Processings->find( $processing_id );
232
    unless ($processing) {
232
    unless ($processing) {
233
        return $c->render(
233
        return $c->render(
(-)a/Koha/REST/V1/Preservation/Trains.pm (-19 / +19 lines)
Lines 58-64 sub get { Link Here
58
    my $c = shift->openapi->valid_input or return;
58
    my $c = shift->openapi->valid_input or return;
59
59
60
    return try {
60
    return try {
61
        my $train_id = $c->validation->param('train_id');
61
        my $train_id = $c->param('train_id');
62
        my $train    = $c->objects->find( Koha::Preservation::Trains->search, $train_id );
62
        my $train    = $c->objects->find( Koha::Preservation::Trains->search, $train_id );
63
63
64
        unless ($train) {
64
        unless ($train) {
Lines 91-97 sub add { Link Here
91
        Koha::Database->new->schema->txn_do(
91
        Koha::Database->new->schema->txn_do(
92
            sub {
92
            sub {
93
93
94
                my $body = $c->validation->param('body');
94
                my $body = $c->req->json;
95
95
96
                my $train = Koha::Preservation::Train->new_from_api($body)->store;
96
                my $train = Koha::Preservation::Train->new_from_api($body)->store;
97
97
Lines 155-161 Controller function that handles updating a Koha::Preservation::Train object Link Here
155
sub update {
155
sub update {
156
    my $c = shift->openapi->valid_input or return;
156
    my $c = shift->openapi->valid_input or return;
157
157
158
    my $train_id = $c->validation->param('train_id');
158
    my $train_id = $c->param('train_id');
159
    my $train = Koha::Preservation::Trains->find( $train_id );
159
    my $train = Koha::Preservation::Trains->find( $train_id );
160
160
161
    unless ($train) {
161
    unless ($train) {
Lines 169-175 sub update { Link Here
169
        Koha::Database->new->schema->txn_do(
169
        Koha::Database->new->schema->txn_do(
170
            sub {
170
            sub {
171
171
172
                my $body = $c->validation->param('body');
172
                my $body = $c->req->json;
173
173
174
                $train->set_from_api($body)->store;
174
                $train->set_from_api($body)->store;
175
175
Lines 226-232 Controller function that handles deleting a Koha::Preservation::Train object Link Here
226
sub delete {
226
sub delete {
227
    my $c = shift->openapi->valid_input or return;
227
    my $c = shift->openapi->valid_input or return;
228
228
229
    my $train = Koha::Preservation::Trains->find( $c->validation->param('train_id') );
229
    my $train = Koha::Preservation::Trains->find( $c->param('train_id') );
230
    unless ($train) {
230
    unless ($train) {
231
        return $c->render(
231
        return $c->render(
232
            status  => 404,
232
            status  => 404,
Lines 255-261 Controller function that handles getting an item from a train Link Here
255
sub get_item {
255
sub get_item {
256
    my $c = shift->openapi->valid_input or return;
256
    my $c = shift->openapi->valid_input or return;
257
257
258
    my $train_id = $c->validation->param('train_id');
258
    my $train_id = $c->param('train_id');
259
    my $train = Koha::Preservation::Trains->find( $train_id );
259
    my $train = Koha::Preservation::Trains->find( $train_id );
260
260
261
    unless ($train) {
261
    unless ($train) {
Lines 265-271 sub get_item { Link Here
265
        );
265
        );
266
    }
266
    }
267
267
268
    my $train_item_id = $c->validation->param('train_item_id');
268
    my $train_item_id = $c->param('train_item_id');
269
269
270
    my $train_item = $c->objects->find(Koha::Preservation::Train::Items->search, { train_item_id => $train_item_id, train_id => $train_id });
270
    my $train_item = $c->objects->find(Koha::Preservation::Train::Items->search, { train_item_id => $train_item_id, train_id => $train_id });
271
271
Lines 297-303 Controller function that handles adding items in batch to a train Link Here
297
sub add_items {
297
sub add_items {
298
    my $c = shift->openapi->valid_input or return;
298
    my $c = shift->openapi->valid_input or return;
299
299
300
    my $train_id = $c->validation->param('train_id');
300
    my $train_id = $c->param('train_id');
301
    my $train = Koha::Preservation::Trains->find( $train_id );
301
    my $train = Koha::Preservation::Trains->find( $train_id );
302
302
303
    unless ($train) {
303
    unless ($train) {
Lines 307-313 sub add_items { Link Here
307
        );
307
        );
308
    }
308
    }
309
309
310
    my $body = $c->validation->every_param('body');
310
    my $body = $c->req->json;
311
    return try {
311
    return try {
312
        Koha::Database->new->schema->txn_do(
312
        Koha::Database->new->schema->txn_do(
313
            sub {
313
            sub {
Lines 339-345 Controller function that handles adding a new item to a train Link Here
339
sub add_item {
339
sub add_item {
340
    my $c = shift->openapi->valid_input or return;
340
    my $c = shift->openapi->valid_input or return;
341
341
342
    my $train_id = $c->validation->param('train_id');
342
    my $train_id = $c->param('train_id');
343
    my $train = Koha::Preservation::Trains->find( $train_id );
343
    my $train = Koha::Preservation::Trains->find( $train_id );
344
344
345
    unless ($train) {
345
    unless ($train) {
Lines 349-355 sub add_item { Link Here
349
        );
349
        );
350
    }
350
    }
351
351
352
    my $body = $c->validation->param('body');
352
    my $body = $c->req->json;
353
    return try {
353
    return try {
354
        Koha::Database->new->schema->txn_do(
354
        Koha::Database->new->schema->txn_do(
355
            sub {
355
            sub {
Lines 408-414 Controller function that handles copying an item from a train to an other Link Here
408
sub copy_item {
408
sub copy_item {
409
    my $c = shift->openapi->valid_input or return;
409
    my $c = shift->openapi->valid_input or return;
410
410
411
    my $train_id = $c->validation->param('train_id');
411
    my $train_id = $c->param('train_id');
412
    my $train = Koha::Preservation::Trains->find( $train_id );
412
    my $train = Koha::Preservation::Trains->find( $train_id );
413
413
414
    unless ($train) {
414
    unless ($train) {
Lines 418-424 sub copy_item { Link Here
418
        );
418
        );
419
    }
419
    }
420
420
421
    my $train_item_id = $c->validation->param('train_item_id');
421
    my $train_item_id = $c->param('train_item_id');
422
422
423
    my $train_item = Koha::Preservation::Train::Items->search({ train_item_id => $train_item_id, train_id => $train_id })->single;
423
    my $train_item = Koha::Preservation::Train::Items->search({ train_item_id => $train_item_id, train_id => $train_id })->single;
424
424
Lines 429-435 sub copy_item { Link Here
429
        );
429
        );
430
    }
430
    }
431
431
432
    my $body = $c->validation->param('body');
432
    my $body = $c->req->json;
433
    return try {
433
    return try {
434
        Koha::Database->new->schema->txn_do(
434
        Koha::Database->new->schema->txn_do(
435
            sub {
435
            sub {
Lines 512-518 Controller function that handles updating an item from a train Link Here
512
sub update_item {
512
sub update_item {
513
    my $c = shift->openapi->valid_input or return;
513
    my $c = shift->openapi->valid_input or return;
514
514
515
    my $train_id = $c->validation->param('train_id');
515
    my $train_id = $c->param('train_id');
516
    my $train = Koha::Preservation::Trains->find( $train_id );
516
    my $train = Koha::Preservation::Trains->find( $train_id );
517
517
518
    unless ($train) {
518
    unless ($train) {
Lines 522-528 sub update_item { Link Here
522
        );
522
        );
523
    }
523
    }
524
524
525
    my $train_item_id = $c->validation->param('train_item_id');
525
    my $train_item_id = $c->param('train_item_id');
526
526
527
    my $train_item = Koha::Preservation::Train::Items->search({ train_item_id => $train_item_id, train_id => $train_id })->single;
527
    my $train_item = Koha::Preservation::Train::Items->search({ train_item_id => $train_item_id, train_id => $train_id })->single;
528
528
Lines 536-542 sub update_item { Link Here
536
    return try {
536
    return try {
537
        Koha::Database->new->schema->txn_do(
537
        Koha::Database->new->schema->txn_do(
538
            sub {
538
            sub {
539
                my $body       = $c->validation->param('body');
539
                my $body       = $c->req->json;
540
                my $attributes = delete $body->{attributes} // [];
540
                my $attributes = delete $body->{attributes} // [];
541
541
542
                $train_item->set_from_api($body)->store;
542
                $train_item->set_from_api($body)->store;
Lines 560-566 Controller function that handles removing an item from a train Link Here
560
sub remove_item {
560
sub remove_item {
561
    my $c = shift->openapi->valid_input or return;
561
    my $c = shift->openapi->valid_input or return;
562
562
563
    my $train_id = $c->validation->param('train_id');
563
    my $train_id = $c->param('train_id');
564
    my $train = Koha::Preservation::Trains->find( $train_id );
564
    my $train = Koha::Preservation::Trains->find( $train_id );
565
565
566
    unless ($train) {
566
    unless ($train) {
Lines 570-576 sub remove_item { Link Here
570
        );
570
        );
571
    }
571
    }
572
572
573
    my $train_item_id = $c->validation->param('train_item_id');
573
    my $train_item_id = $c->param('train_item_id');
574
574
575
    my $train_item = $train->items->find($train_item_id);
575
    my $train_item = $train->items->find($train_item_id);
576
576
(-)a/Koha/REST/V1/Preservation/WaitingList.pm (-3 / +2 lines)
Lines 74-80 sub add_items { Link Here
74
    my $c = shift->openapi->valid_input or return;
74
    my $c = shift->openapi->valid_input or return;
75
75
76
    return try {
76
    return try {
77
        my $body = $c->validation->every_param('body');
77
        my $body = $c->req->json;
78
        my $new_not_for_loan = C4::Context->preference('PreservationNotForLoanWaitingListIn');
78
        my $new_not_for_loan = C4::Context->preference('PreservationNotForLoanWaitingListIn');
79
79
80
        Koha::Exceptions::Preservation::MissingSettings->throw( parameter => 'PreservationNotForLoanWaitingListIn' ) unless $new_not_for_loan;
80
        Koha::Exceptions::Preservation::MissingSettings->throw( parameter => 'PreservationNotForLoanWaitingListIn' ) unless $new_not_for_loan;
Lines 126-132 sub remove_item { Link Here
126
    my $c = shift->openapi->valid_input or return;
126
    my $c = shift->openapi->valid_input or return;
127
127
128
    return try {
128
    return try {
129
        my $item_id = $c->validation->param('item_id');
129
        my $item_id = $c->param('item_id');
130
130
131
        my $item = Koha::Items->find($item_id);
131
        my $item = Koha::Items->find($item_id);
132
132
133
- 

Return to bug 30708