conflict resolved
This commit is contained in:
@@ -54,7 +54,7 @@ class SortieController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Définir les relations et l'état initial
|
// Définir les relations et l'état initial
|
||||||
$etat = $etatRepository->findOneBy(['libelle' => 'Créée']);
|
$etat = $etatRepository->findOneBy(['libelle' => 'Ouverte']);
|
||||||
if (!$etat) {
|
if (!$etat) {
|
||||||
$this->addFlash('error', 'Erreur interne : état introuvable.');
|
$this->addFlash('error', 'Erreur interne : état introuvable.');
|
||||||
return $this->redirectToRoute('sortie_create');
|
return $this->redirectToRoute('sortie_create');
|
||||||
@@ -100,10 +100,12 @@ class SortieController extends AbstractController
|
|||||||
public function inscription(
|
public function inscription(
|
||||||
string $id,
|
string $id,
|
||||||
EntityManagerInterface $entityManager,
|
EntityManagerInterface $entityManager,
|
||||||
TokenStorageInterface $tokenStorage
|
TokenStorageInterface $tokenStorage,
|
||||||
|
ParticipantRepository $participantRepository,
|
||||||
): Response {
|
): Response {
|
||||||
$userConnect = $tokenStorage->getToken()?->getUser();
|
$userConnect = $tokenStorage->getToken()?->getUser();
|
||||||
if (!$userConnect) {
|
$participant = $participantRepository->find($userConnect->getIdParticipant());
|
||||||
|
if (!$participant) {
|
||||||
$this->addFlash('error', 'Vous devez être connecté pour vous inscrire.');
|
$this->addFlash('error', 'Vous devez être connecté pour vous inscrire.');
|
||||||
return $this->redirectToRoute('app_login');
|
return $this->redirectToRoute('app_login');
|
||||||
}
|
}
|
||||||
@@ -117,14 +119,14 @@ class SortieController extends AbstractController
|
|||||||
// Conditions supplémentaires pour l'inscription
|
// Conditions supplémentaires pour l'inscription
|
||||||
if ($sortie->getEtat()->getLibelle() !== 'Ouverte') {
|
if ($sortie->getEtat()->getLibelle() !== 'Ouverte') {
|
||||||
$this->addFlash('error', 'Cette sortie n\'est pas ouverte aux inscriptions.');
|
$this->addFlash('error', 'Cette sortie n\'est pas ouverte aux inscriptions.');
|
||||||
} elseif ($sortie->getParticipants()->contains($userConnect)) {
|
} elseif ($sortie->getParticipants()->contains($participant)) {
|
||||||
$this->addFlash('error', 'Vous êtes déjà inscrit à cette sortie.');
|
$this->addFlash('error', 'Vous êtes déjà inscrit à cette sortie.');
|
||||||
} elseif ($sortie->getParticipants()->count() >= $sortie->getNbInscriptionsMax()) {
|
} elseif ($sortie->getParticipants()->count() >= $sortie->getNbInscriptionsMax()) {
|
||||||
$this->addFlash('error', 'Cette sortie est complète.');
|
$this->addFlash('error', 'Cette sortie est complète.');
|
||||||
} elseif ($sortie->getDateLimiteInscription() < new DateTime()) {
|
} elseif ($sortie->getDateLimiteInscription() < new DateTime()) {
|
||||||
$this->addFlash('error', "La date limite d'inscription est dépassée");
|
$this->addFlash('error', "La date limite d'inscription est dépassée");
|
||||||
} else {
|
} else {
|
||||||
$sortie->addParticipant($userConnect);
|
$sortie->addParticipant($participant);
|
||||||
$entityManager->persist($sortie);
|
$entityManager->persist($sortie);
|
||||||
$entityManager->flush();
|
$entityManager->flush();
|
||||||
$this->addFlash('success', 'Votre inscription a été validée.');
|
$this->addFlash('success', 'Votre inscription a été validée.');
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ class EtatFixtures extends Fixture
|
|||||||
public function load(ObjectManager $manager): void
|
public function load(ObjectManager $manager): void
|
||||||
{
|
{
|
||||||
$etats = [
|
$etats = [
|
||||||
'Créée',
|
|
||||||
'Ouverte',
|
'Ouverte',
|
||||||
'Clôturée',
|
'Clôturée',
|
||||||
'En cours',
|
'En cours',
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ class Participant implements UserInterface, PasswordAuthenticatedUserInterface
|
|||||||
{
|
{
|
||||||
if (!$this->sortiesParticipants->contains($sortiesParticipant)) {
|
if (!$this->sortiesParticipants->contains($sortiesParticipant)) {
|
||||||
$this->sortiesParticipants->add($sortiesParticipant);
|
$this->sortiesParticipants->add($sortiesParticipant);
|
||||||
$sortiesParticipant->addParticipant($this);
|
$sortiesParticipant->addParticipant($this); // Synchronise avec Sortie
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -92,14 +92,6 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{# {% if app.user %}#}
|
|
||||||
{# <div class="mt-6 flex">#}
|
|
||||||
{# <a href="{{ path('sortie_inscription') }}">#}
|
|
||||||
{# <button class="px-6 py-3 bg-green-500 text-white rounded-md shadow hover:bg-green-600">M'inscrire</button>#}
|
|
||||||
{# </a>#}
|
|
||||||
{# </div>#}
|
|
||||||
{# {% endif %}#}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="lg:col-span-5 bg-white rounded-lg shadow p-6">
|
<div class="lg:col-span-5 bg-white rounded-lg shadow p-6">
|
||||||
|
|||||||
Reference in New Issue
Block a user