Bug 23893: Use in /cities

This patch makes the cities controller use the new methods from
Koha::Object.

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

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Tomas Cohen Arazi 2019-11-12 09:59:53 -03:00 committed by Martin Renvoize
parent 340f77732a
commit c46c86b3e7
No known key found for this signature in database
GPG Key ID: 422B469130441A0F
1 changed files with 2 additions and 3 deletions

View File

@ -76,7 +76,7 @@ sub add {
my $c = shift->openapi->valid_input or return;
return try {
my $city = Koha::City->new( _to_model( $c->validation->param('body') ) );
my $city = Koha::City->new_from_api( $c->validation->param('body') );
$city->store;
$c->res->headers->location( $c->req->url->to_string . '/' . $city->cityid );
return $c->render(
@ -115,8 +115,7 @@ sub update {
}
return try {
my $params = $c->req->json;
$city->set( _to_model($params) );
$city->set_from_api( $c->validation->param('body') );
$city->store();
return $c->render( status => 200, openapi => $city->to_api );
}