Bug 27894: Adapt /holds/:hold_id/pickup_locations
This patch makes the controller for the route, return all valid pickup locations (i.e. pickup_location => 1) when AllowHoldPolicyOverride is set to 'Allow', but also adds a calculated attribute: 'needs_override' so the consumer knows the specific pickup location needs an override (and thus be able to provide visual feedback on a single run). To test: 1. Apply the regression tests 2. Run: $ kshell k$ prove t/db_dependent/api/v1/holds.t => FAILURE: Tests fail, the change is not implemented 3. Apply this patch 4. Repeat 2 => SUCCESS: Tests pass! 5. Sign off :-D Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
f98c4cec8e
commit
d8be3d5084
|
|
@ -472,10 +472,35 @@ sub pickup_locations {
|
|||
}
|
||||
|
||||
my $pickup_locations = $c->objects->search( $ps_set );
|
||||
my @response = ();
|
||||
|
||||
if ( C4::Context->preference('AllowHoldPolicyOverride') ) {
|
||||
|
||||
my $libraries_rs = Koha::Libraries->search( { pickup_location => 1 } );
|
||||
my $libraries = $c->objects->search($libraries_rs);
|
||||
|
||||
@response = map {
|
||||
my $library = $_;
|
||||
$library->{needs_override} = (
|
||||
any { $_->{library_id} eq $library->{library_id} }
|
||||
@{$pickup_locations}
|
||||
)
|
||||
? Mojo::JSON->false
|
||||
: Mojo::JSON->true;
|
||||
$library;
|
||||
} @{$libraries};
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => \@response
|
||||
);
|
||||
}
|
||||
|
||||
@response = map { $_->{needs_override} = Mojo::JSON->false; $_; } @{$pickup_locations};
|
||||
|
||||
return $c->render(
|
||||
status => 200,
|
||||
openapi => $pickup_locations
|
||||
openapi => \@response
|
||||
);
|
||||
}
|
||||
catch {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,10 @@
|
|||
"smtp_server": {
|
||||
"type": ["object", "null"],
|
||||
"description": "The library effective SMTP server"
|
||||
},
|
||||
"needs_override": {
|
||||
"type": "boolean",
|
||||
"description": "If the library needs an override to act as pickup location for a hold"
|
||||
}
|
||||
},
|
||||
"additionalProperties": false,
|
||||
|
|
|
|||
Loading…
Reference in New Issue