Pārlūkot izejas kodu

Bug 28254: Make PUT /holds/:hold_id/pickup_location honour x-koha-override

This patch adds a new parameter (x-koha-override header) to the route,
and makes the controller pass this information (override requested) when
the AllowHoldPolicyOverride syspref is set, to
Koha::Hold->set_pickup_location.

This way, under certain conditions, we can be sure the update wont'
fail.

To test:
1. Apply this patchset
2. Run:
   $ kshell
  k$ prove t/db_dependent/api/v1/holds.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
21.05.x
Tomás Cohen Arazi pirms 3 gadiem
revīziju iesūtīja Jonathan Druart
vecāks
revīzija
01b9367625
  1. 10
      Koha/REST/V1/Holds.pm
  2. 7
      api/v1/swagger/paths/holds.json

10
Koha/REST/V1/Holds.pm

@ -533,7 +533,15 @@ sub update_pickup_location {
return try {
$hold->set_pickup_location({ library_id => $pickup_library_id });
my $overrides = $c->stash('koha.overrides');
my $can_override = $overrides->{any} && C4::Context->preference('AllowHoldPolicyOverride');
$hold->set_pickup_location(
{
library_id => $pickup_library_id,
override => $can_override
}
);
return $c->render(
status => 200,

7
api/v1/swagger/paths/holds.json

@ -628,6 +628,13 @@
"operationId": "getHoldPickupLocations",
"tags": ["holds"],
"parameters": [
{
"name": "x-koha-override",
"description": "Comma-separated list of overrides (valid values: any)",
"in": "header",
"type": "string",
"required": false
},
{
"$ref": "../parameters.json#/hold_id_pp"
},

Notiek ielāde…
Atcelt
Saglabāt