mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add route for scope on participation
This commit is contained in:
parent
f3eb418409
commit
f1d5d9840e
@ -24,13 +24,16 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Chill\MainBundle\Entity\RoleScope;
|
||||
use Symfony\Component\Serializer\Annotation\Groups;
|
||||
use Symfony\Component\Serializer\Annotation\DiscriminatorMap;
|
||||
|
||||
/**
|
||||
* @ORM\Entity()
|
||||
* @ORM\Table(name="scopes")
|
||||
* @ORM\Cache(usage="NONSTRICT_READ_WRITE", region="acl_cache_region")
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @DiscriminatorMap(typeProperty="type", mapping={
|
||||
* "scope"=Scope::class
|
||||
* })
|
||||
*/
|
||||
class Scope
|
||||
{
|
||||
@ -40,6 +43,7 @@ class Scope
|
||||
* @ORM\Id
|
||||
* @ORM\Column(name="id", type="integer")
|
||||
* @ORM\GeneratedValue(strategy="AUTO")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $id;
|
||||
|
||||
@ -49,6 +53,7 @@ class Scope
|
||||
* @var array
|
||||
*
|
||||
* @ORM\Column(type="json_array")
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
private $name = [];
|
||||
|
||||
|
@ -16,6 +16,7 @@ use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Symfony\Component\Serializer\Exception\RuntimeException;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Resource;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
|
||||
class AccompanyingCourseApiController extends ApiController
|
||||
{
|
||||
@ -72,6 +73,11 @@ class AccompanyingCourseApiController extends ApiController
|
||||
return $this->addRemoveSomething('resource', $id, $request, $_format, 'resource', Resource::class);
|
||||
}
|
||||
|
||||
public function scopeApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
return $this->addRemoveSomething('scope', $id, $request, $_format, 'scope', Scope::class);
|
||||
}
|
||||
|
||||
public function commentApi($id, Request $request, string $_format): Response
|
||||
{
|
||||
return $this->addRemoveSomething('comment', $id, $request, $_format, 'comment', Comment::class);
|
||||
|
@ -377,6 +377,18 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
],
|
||||
'scope' => [
|
||||
'methods' => [
|
||||
Request::METHOD_POST => true,
|
||||
Request::METHOD_DELETE => true,
|
||||
Request::METHOD_GET => false,
|
||||
Request::METHOD_HEAD => false,
|
||||
],
|
||||
'roles' => [
|
||||
Request::METHOD_POST => \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE,
|
||||
Request::METHOD_DELETE=> \Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter::SEE
|
||||
]
|
||||
]
|
||||
|
||||
]
|
||||
|
@ -1,11 +1,41 @@
|
||||
components:
|
||||
schemas:
|
||||
# should go to main
|
||||
Date:
|
||||
type: object
|
||||
properties:
|
||||
datetime:
|
||||
type: string
|
||||
format: date-time
|
||||
Scope:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
enum:
|
||||
- scope
|
||||
name:
|
||||
type: object
|
||||
additionalProperties:
|
||||
type: string
|
||||
example:
|
||||
fr: Social
|
||||
ScopeById:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
type:
|
||||
type: string
|
||||
enum:
|
||||
- scope
|
||||
required:
|
||||
- id
|
||||
- scope
|
||||
|
||||
# ok to stay here
|
||||
Person:
|
||||
type: object
|
||||
properties:
|
||||
@ -413,7 +443,7 @@ paths:
|
||||
delete:
|
||||
tags:
|
||||
- person
|
||||
summary: "Remove the resource"
|
||||
summary: "Remove the comment"
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
@ -424,7 +454,7 @@ paths:
|
||||
format: integer
|
||||
minimum: 1
|
||||
requestBody:
|
||||
description: "A resource"
|
||||
description: "A comment"
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
@ -439,3 +469,68 @@ paths:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "object with validation errors"
|
||||
|
||||
/1.0/person/accompanying-course/{id}/scope.json:
|
||||
post:
|
||||
tags:
|
||||
- person
|
||||
summary: "Add a scope to the accompanying course"
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
description: The accompanying period's id
|
||||
schema:
|
||||
type: integer
|
||||
format: integer
|
||||
minimum: 1
|
||||
requestBody:
|
||||
description: "A comment"
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Scope'
|
||||
examples:
|
||||
add a scope:
|
||||
value:
|
||||
type: scope
|
||||
id: 5
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
404:
|
||||
description: "Not found"
|
||||
200:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "object with validation errors"
|
||||
delete:
|
||||
tags:
|
||||
- person
|
||||
summary: "Remove the scope"
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
description: The accompanying period's id
|
||||
schema:
|
||||
type: integer
|
||||
format: integer
|
||||
minimum: 1
|
||||
requestBody:
|
||||
description: "A scope with his id"
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ScopeById'
|
||||
responses:
|
||||
401:
|
||||
description: "Unauthorized"
|
||||
404:
|
||||
description: "Not found"
|
||||
200:
|
||||
description: "OK"
|
||||
422:
|
||||
description: "object with validation errors"
|
||||
|
Loading…
x
Reference in New Issue
Block a user