diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3dfe9d5240096ffba1775d88d5fbcfbfde7cb791..b43488c214b62661db641e6bdb9f9688f5a185f2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,7 +2,7 @@ image: docker:19.03.12 variables: DOCKER_TLS_CERTDIR: "/certs" - IMAGE_VER: 2.0.0 + IMAGE_VER: 2.1.0 services: - docker:19.03.12-dind diff --git a/lib/CF/Controller/Events.pm b/lib/CF/Controller/Events.pm index cdbc1baff953850e134d85477179665693ad4bde..0b5b92dc0ee477c5425020011a2326335cade929 100644 --- a/lib/CF/Controller/Events.pm +++ b/lib/CF/Controller/Events.pm @@ -30,8 +30,10 @@ sub create ($c) { sub get ($c) { $c->openapi->valid_input or return; - my $event = $c->schema->resultset('Event')->find($c->stash->{id}); - return $c->error(404, 'Event not found') if ! $event; + my $event = $c->schema->resultset('Event')->find({ + id => $c->stash->{id}, + }); + return $c->error(404, 'Event not found') if ! $event || $event->deleted; my $formatted = $event->format(); $formatted->{acl} = []; @@ -49,7 +51,7 @@ sub get ($c) { return $c->error(404, 'Event not found'); } - $c->render(openapi => $c->spec_filter($formatted, 'Event')); + $c->render(json => $c->spec_filter($formatted, 'Event')); # BUG: error if openpi } sub list ($c) { @@ -98,14 +100,11 @@ sub update ($c) { return $c->error(404, 'Event not found') if ! $event; my $update = $c->prepare_update_data( $event, $c->req->json ); - my $guard = $c->schema->txn_scope_guard; - - $event->update({ - %{ $update }, - changed => \'now()', - }); + my $guard = $c->schema->txn_scope_guard; + $event->update({ %{ $update }, }); $guard->commit; + $c->render(status => 204, text => ''); } @@ -117,8 +116,9 @@ sub delete ($c) { my $guard = $c->schema->txn_scope_guard; $event->update({ deleted => \'now()', }); - $guard->commit; + $c->render(status => 204, text => ''); } + 1; diff --git a/lib/CF/Schema/ResultSet/Event.pm b/lib/CF/Schema/ResultSet/Event.pm new file mode 100644 index 0000000000000000000000000000000000000000..79f44523bff3511caf0218aede28d6cdb85ec1fa --- /dev/null +++ b/lib/CF/Schema/ResultSet/Event.pm @@ -0,0 +1,15 @@ +package CF::Schema::ResultSet::Event; + +use strict; +use warnings; + +use base 'DBIx::Class::ResultSet'; + +use constant PROTECTED_FIELDS => [qw( + id + uuid + owner_id + deleted +)]; + +1; diff --git a/openapi.yaml b/openapi.yaml index 8911ab3215a1adf0e9482729b5e0a74a7a9b9f9d..1b59267fe853bac1b1de73fe89eb4bf7e961d6d6 100644 --- a/openapi.yaml +++ b/openapi.yaml @@ -401,6 +401,8 @@ paths: required: false schema: type: boolean + default: false + example: true - name: sort description: "Razeni" in: query @@ -431,7 +433,7 @@ paths: get: x-mojo-to: events#get security: - - Bearer: ['optional'] + - Bearer: ['optional', '*'] tags: - events summary: "Detail udalosti" @@ -440,6 +442,7 @@ paths: - name: id in: path required: true + example: 100345 description: "ID" schema: type: integer @@ -462,6 +465,7 @@ paths: - name: id in: path required: true + example: 100345 description: "ID" schema: type: integer