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

(-)a/Koha/REST/V1/Hold.pm (-1 / +7 lines)
Lines 153-162 sub edit { Link Here
153
        reserve_id => $reserve_id,
153
        reserve_id => $reserve_id,
154
        branchcode => $branchcode,
154
        branchcode => $branchcode,
155
        rank => $priority,
155
        rank => $priority,
156
        suspend_until => $suspend_until,
157
    };
156
    };
158
157
159
    C4::Reserves::ModReserve($params);
158
    C4::Reserves::ModReserve($params);
159
160
    my $borrowernumber = $reserve->{borrowernumber};
161
    if (C4::Reserves::CanReserveBeCanceledFromOpac($reserve_id, $borrowernumber)){
162
        C4::Reserves::ToggleSuspend( $reserve_id, $suspend_until ) if
163
            (defined $body->{suspend} || $suspend_until);
164
    }
165
160
    $reserve = Koha::Holds->find($reserve_id);
166
    $reserve = Koha::Holds->find($reserve_id);
161
167
162
    return $c->render( status => 200, openapi => $reserve );
168
    return $c->render( status => 200, openapi => $reserve );
(-)a/api/v1/swagger/paths/holds.json (-1 / +5 lines)
Lines 273-281 Link Here
273
                "description": "Pickup location",
273
                "description": "Pickup location",
274
                "type": "string"
274
                "type": "string"
275
              },
275
              },
276
              "suspend": {
277
                "description": "Suspend hold",
278
                "type": "boolean"
279
              },
276
              "suspend_until": {
280
              "suspend_until": {
277
                "description": "Suspend until",
281
                "description": "Suspend until",
278
                "type": "string",
282
                "type": ["string", "null"],
279
                "format": "date"
283
                "format": "date"
280
              }
284
              }
281
            }
285
            }
(-)a/t/db_dependent/api/v1/holds.t (-2 / +21 lines)
Lines 225-231 subtest "Test endpoints without permission" => sub { Link Here
225
      ->status_is(403);
225
      ->status_is(403);
226
};
226
};
227
subtest "Test endpoints without permission, but accessing own object" => sub {
227
subtest "Test endpoints without permission, but accessing own object" => sub {
228
    plan tests => 26;
228
    plan tests => 36;
229
229
230
    my $reserve_id3 = C4::Reserves::AddReserve($branchcode, $nopermission->{'borrowernumber'},
230
    my $reserve_id3 = C4::Reserves::AddReserve($branchcode, $nopermission->{'borrowernumber'},
231
    $biblionumber, undef, 2, undef, undef, undef, '', $itemnumber, 'W');
231
    $biblionumber, undef, 2, undef, undef, undef, '', $itemnumber, 'W');
Lines 319-324 subtest "Test endpoints without permission, but accessing own object" => sub { Link Here
319
      ->status_is(200)
319
      ->status_is(200)
320
      ->json_is('/reserve_id', $reserve_id3)
320
      ->json_is('/reserve_id', $reserve_id3)
321
      ->json_is('/branchcode', $branchcode2);
321
      ->json_is('/branchcode', $branchcode2);
322
323
    $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => {
324
        suspend_until => $suspend_until
325
    });
326
    $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id});
327
    $t->request_ok($tx) # create hold to myself
328
      ->status_is(200)
329
      ->json_is('/reserve_id', $reserve_id3)
330
      ->json_is('/suspend', Mojo::JSON->true)
331
      ->json_like('/suspend_until', qr/^$suspend_until/);
332
333
    $tx = $t->ua->build_tx(PUT => "/api/v1/holds/$reserve_id3" => json => {
334
        suspend => Mojo::JSON->false
335
    });
336
    $tx->req->cookies({name => 'CGISESSID', value => $session_nopermission->id});
337
    $t->request_ok($tx) # create hold to myself
338
      ->status_is(200)
339
      ->json_is('/reserve_id', $reserve_id3)
340
      ->json_is('/suspend', Mojo::JSON->false)
341
      ->json_is('/suspend_until', undef);
322
};
342
};
323
343
324
subtest "Test endpoints with permission" => sub {
344
subtest "Test endpoints with permission" => sub {
325
- 

Return to bug 19072