Bug 37592: (QA follow-up) Fetch database fields for api return
Creation and Modification times are maintained by the database, but on add/update we were not fetching the updated fields from the database for the api response. This patch corrects that and also updates the api schema to reflect that these are readOnly fields. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
parent
40d9f2cf18
commit
90ba1c1bfe
2 changed files with 4 additions and 0 deletions
|
@ -77,6 +77,7 @@ sub add {
|
||||||
return try {
|
return try {
|
||||||
my $booking = Koha::Booking->new_from_api( $c->req->json );
|
my $booking = Koha::Booking->new_from_api( $c->req->json );
|
||||||
$booking->store;
|
$booking->store;
|
||||||
|
$booking->discard_changes;
|
||||||
$c->res->headers->location( $c->req->url->to_string . '/' . $booking->booking_id );
|
$c->res->headers->location( $c->req->url->to_string . '/' . $booking->booking_id );
|
||||||
return $c->render(
|
return $c->render(
|
||||||
status => 201,
|
status => 201,
|
||||||
|
@ -118,6 +119,7 @@ sub update {
|
||||||
return try {
|
return try {
|
||||||
$booking->set_from_api( $c->req->json );
|
$booking->set_from_api( $c->req->json );
|
||||||
$booking->store();
|
$booking->store();
|
||||||
|
$booking->discard_changes;
|
||||||
return $c->render( status => 200, openapi => $c->objects->to_api($booking) );
|
return $c->render( status => 200, openapi => $c->objects->to_api($booking) );
|
||||||
} catch {
|
} catch {
|
||||||
$c->unhandled_exception($_);
|
$c->unhandled_exception($_);
|
||||||
|
|
|
@ -12,6 +12,7 @@ properties:
|
||||||
type: integer
|
type: integer
|
||||||
creation_date:
|
creation_date:
|
||||||
description: Creation date and time of this booking
|
description: Creation date and time of this booking
|
||||||
|
readOnly: true
|
||||||
format: date-time
|
format: date-time
|
||||||
type: string
|
type: string
|
||||||
end_date:
|
end_date:
|
||||||
|
@ -30,6 +31,7 @@ properties:
|
||||||
- 'null'
|
- 'null'
|
||||||
modification_date:
|
modification_date:
|
||||||
description: Modification date and time of this booking
|
description: Modification date and time of this booking
|
||||||
|
readOnly: true
|
||||||
format: date-time
|
format: date-time
|
||||||
type: string
|
type: string
|
||||||
patron_id:
|
patron_id:
|
||||||
|
|
Loading…
Reference in a new issue