mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Event: move validation to annotation and add UniqueEntity constraint on Participation
This commit is contained in:
parent
6d04e477f8
commit
e586b8ee5e
@ -236,6 +236,7 @@ final class ParticipationController extends AbstractController
|
|||||||
return $this->render('@ChillEvent/Participation/new.html.twig', [
|
return $this->render('@ChillEvent/Participation/new.html.twig', [
|
||||||
'form' => $form->createView(),
|
'form' => $form->createView(),
|
||||||
'participation' => $participation,
|
'participation' => $participation,
|
||||||
|
'ignored_participations' => [],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ use DateTime;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Event.
|
* Class Event.
|
||||||
@ -40,7 +41,8 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
|
|||||||
use TrackUpdateTrait;
|
use TrackUpdateTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")
|
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Center")A
|
||||||
|
* @Assert\NotNull()
|
||||||
*/
|
*/
|
||||||
private ?Center $center = null;
|
private ?Center $center = null;
|
||||||
|
|
||||||
@ -70,6 +72,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Column(type="string", length=150)
|
* @ORM\Column(type="string", length=150)
|
||||||
|
* @Assert\NotBlank()
|
||||||
*/
|
*/
|
||||||
private ?string $name = null;
|
private ?string $name = null;
|
||||||
|
|
||||||
@ -84,6 +87,7 @@ class Event implements HasCenterInterface, HasScopeInterface, TrackCreationInter
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType")
|
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\EventType")
|
||||||
|
* @Assert\NotNull()
|
||||||
*/
|
*/
|
||||||
private ?EventType $type = null;
|
private ?EventType $type = null;
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ use Chill\MainBundle\Entity\Scope;
|
|||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||||
|
|
||||||
@ -36,6 +37,7 @@ use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
|||||||
* })
|
* })
|
||||||
*
|
*
|
||||||
* @ORM\HasLifecycleCallbacks
|
* @ORM\HasLifecycleCallbacks
|
||||||
|
* @UniqueEntity({"event", "person"}, message="event.validation.person_already_participate_to_event")
|
||||||
*/
|
*/
|
||||||
class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface, TrackUpdateInterface, TrackCreationInterface
|
class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterface, TrackUpdateInterface, TrackCreationInterface
|
||||||
{
|
{
|
||||||
@ -66,7 +68,6 @@ class Participation implements \ArrayAccess, HasCenterInterface, HasScopeInterfa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Role")
|
* @ORM\ManyToOne(targetEntity="Chill\EventBundle\Entity\Role")
|
||||||
* @Assert\NotNull()
|
|
||||||
*/
|
*/
|
||||||
private ?Role $role = null;
|
private ?Role $role = null;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ul class="record_actions">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
<li class="cancel">
|
<li class="cancel">
|
||||||
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="btn btn-cancel">
|
<a href="{{ path('chill_event__event_show', { 'event_id' : participation.event.id } ) }}" class="btn btn-cancel">
|
||||||
{{ 'Back to the event'|trans }}
|
{{ 'Back to the event'|trans }}
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
Chill\EventBundle\Entity\Participation:
|
|
||||||
properties:
|
|
||||||
event:
|
|
||||||
- NotNull: ~
|
|
||||||
status:
|
|
||||||
- NotNull: ~
|
|
||||||
person:
|
|
||||||
- NotNull: ~
|
|
||||||
constraints:
|
|
||||||
- Callback: isConsistent
|
|
||||||
|
|
||||||
|
|
||||||
Chill\EventBundle\Entity\Event:
|
|
||||||
properties:
|
|
||||||
name:
|
|
||||||
- Length:
|
|
||||||
min: 3
|
|
||||||
max: 75
|
|
||||||
minMessage: The event name must have at least {{ limit }} characters.
|
|
||||||
maxMessage: The event name must have maximum {{ limit }} characters.
|
|
||||||
type:
|
|
||||||
- NotNull: ~
|
|
||||||
circle:
|
|
||||||
- NotNull: ~
|
|
||||||
center:
|
|
||||||
- NotNull: ~
|
|
@ -0,0 +1,3 @@
|
|||||||
|
event:
|
||||||
|
validation:
|
||||||
|
person_already_participate_to_event: L'usager est déjà inscrit à l'événement
|
Loading…
x
Reference in New Issue
Block a user