From 732587fa848792dc449a6e074841584964677c71 Mon Sep 17 00:00:00 2001 From: jleroy2023 Date: Mon, 25 Nov 2024 11:29:27 +0100 Subject: [PATCH 1/3] set administration sortie and delete administration city --- src/Controller/AdminController.php | 76 ++++-------------- templates/admin/city.html.twig | 119 ----------------------------- templates/admin/sidebar.html.twig | 9 +-- templates/admin/sortie.html.twig | 69 +++++++++++++++++ 4 files changed, 85 insertions(+), 188 deletions(-) delete mode 100644 templates/admin/city.html.twig create mode 100644 templates/admin/sortie.html.twig diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 92512f8..77c56dd 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -8,6 +8,7 @@ use App\Entity\Site; use App\Entity\Ville; use App\Repository\ParticipantRepository; use App\Repository\SiteRepository; +use App\Repository\SortieRepository; use App\Repository\VilleRepository; use Doctrine\Common\Collections\Collection; use Doctrine\ORM\EntityManagerInterface; @@ -278,68 +279,6 @@ class AdminController extends AbstractController return $response; } - //Gestion des villes - #[Route('/admin/city', name: 'app_adminCity')] - public function adminCity(VilleRepository $villeRepository, TokenStorageInterface $tokenStorage): Response - { - $token = $tokenStorage->getToken(); - $userConnect = $token?->getUser(); - return $this->render('admin/city.html.twig', [ - 'profile' => $userConnect, - 'citys' => $villeRepository->findAll(), - 'controller_name' => 'AdminController', - ]); - } - #[Route('/admin/city/add', name: 'app_adminCityAdd', methods: ['POST'])] - public function adminCityAdd(Request $request, EntityManagerInterface $entityManager): Response - { - try { - // Récupérer les données envoyées par le formulaire - $postalCode = $request->request->get('postalCode'); - $cityName = $request->request->get('citySelect'); - - // Vérifier que les champs ne sont pas vides - if (!$postalCode || !$cityName) { - return new Response('Tous les champs sont requis.', Response::HTTP_BAD_REQUEST); - } - - // Créer une nouvelle entité City et définir ses propriétés - $city = new Ville(); - $city->setNom($cityName); - $city->setCodePostal($postalCode); - - // Enregistrer la ville dans la base de données - $entityManager->persist($city); - $entityManager->flush(); - $this->addFlash('success', "Ville ajouté !"); - return $this->redirectToRoute('app_adminCity'); - } catch(\Exception $e) { - $this->addFlash('error', "Erreur : " . $e->getMessage()); - return $this->redirectToRoute('app_adminCity'); - } - } - #[Route('/admin/city/delete/{id}', name: 'app_adminCityDelete')] - public function adminCityDelete(string $id, VilleRepository $villeRepository, EntityManagerInterface $entityManager): RedirectResponse - { - // Récupérer la ville à supprimer - $city = $villeRepository->find($id); - - // Vérifier si la ville existe - if (!$city) { - // Si la ville n'existe pas, rediriger avec un message d'erreur - $this->addFlash('error', 'La ville demandée n\'existe pas.'); - return $this->redirectToRoute('app_adminCity'); // Rediriger vers la liste des villes - } - - // Supprimer la ville - $entityManager->remove($city); - $entityManager->flush(); - - // Ajouter un message de succès et rediriger vers la liste des villes - $this->addFlash('success', 'Ville supprimée avec succès.'); - return $this->redirectToRoute('app_adminCity'); - } - //Gestion des sites #[Route('/admin/site', name: 'app_adminSite')] public function adminSite(SiteRepository $siteRepository, TokenStorageInterface $tokenStorage): Response @@ -446,4 +385,17 @@ class AdminController extends AbstractController return $this->redirectToRoute('home'); } } + + #[Route('/admin/sortie', name: 'app_adminSortie')] + public function sortie(TokenStorageInterface $tokenStorage, SortieRepository $sortieRepository): Response + { + $token = $tokenStorage->getToken(); + $userConnect = $token?->getUser(); + return $this->render('admin/sortie.html.twig', [ + 'profile' => $userConnect, + 'controller_name' => 'AdminController', + 'sorties' => $sortieRepository->findAll(), + ]); + } + } diff --git a/templates/admin/city.html.twig b/templates/admin/city.html.twig deleted file mode 100644 index a9260a1..0000000 --- a/templates/admin/city.html.twig +++ /dev/null @@ -1,119 +0,0 @@ -{% extends 'main/base.html.twig' %} - -{% block title %}📣 Sortie.com Admin City 🔊{% endblock %} - -{% block content %} -
- {% include 'admin/sidebar.html.twig' %} - - -
-

Gestion des villes

- - -
- - -
- - -
- - - - - - - - - - {% for city in citys %} - - - - - - {% else %} - - - - {% endfor %} - -
NomCode postalActions
{{ city.nom }}{{ city.codePostal }} - Supprimer -
Aucune ville trouvée
-
-
- - - - - -
-{% endblock %} diff --git a/templates/admin/sidebar.html.twig b/templates/admin/sidebar.html.twig index 5d34fef..4f8ae2b 100644 --- a/templates/admin/sidebar.html.twig +++ b/templates/admin/sidebar.html.twig @@ -12,8 +12,8 @@
  • - - 🏙 Villes + + 🚪 Sortie
  • @@ -21,10 +21,5 @@ 📍 Sites
  • -
  • - - ⚙ Paramètres - -
  • \ No newline at end of file diff --git a/templates/admin/sortie.html.twig b/templates/admin/sortie.html.twig new file mode 100644 index 0000000..c91d807 --- /dev/null +++ b/templates/admin/sortie.html.twig @@ -0,0 +1,69 @@ +{% extends 'main/base.html.twig' %} + +{% block title %}📣 Sortie.com Admin User 🔊{% endblock %} + +{% block content %} +
    + {% include 'admin/sidebar.html.twig' %} + + +
    +

    Gestion des sorties

    + + +
    +
    + + + + + + + + + + + + + + + + + + {% for sortie in sorties %} + + + + + + + + + + + + + + {% else %} + + + + {% endfor %} + +
    NomDate débutduréeDate fin d'inscriptionNombre limite d'inscriptionOrganisateurSiteLieuEtatActions
    {{ sortie.nom }}{{ sortie.dateHeureDebut }}{{ sortie.duree }}{{ sortie.dateLimiteInscription }}{{ sortie.nbInscriptionsMax }}{{ sortie.organisateur.pseudo }}{{ sortie.site.nom }}{{ sortie.lieu.nom }}{{ sortie.etat.libelle }} + {# {% if not sortie.etat %} + + {% endif %} + + Logo + + + Logo + #} +
    Aucune sortie trouvé
    +
    +
    + +
    +
    +{% endblock %} \ No newline at end of file From 07f2261ea953345181f7a79992deb5d8e294e73b Mon Sep 17 00:00:00 2001 From: jleroy2023 Date: Mon, 25 Nov 2024 11:36:12 +0100 Subject: [PATCH 2/3] set mail server test --- .env | 2 +- src/Controller/AdminController.php | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.env b/.env index cc08693..3c7998c 100644 --- a/.env +++ b/.env @@ -37,5 +37,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 ###< symfony/messenger ### ###> symfony/mailer ### -MAILER_DSN=smtp:// +MAILER_DSN=smtp://dev-test@lidge.fr:N2uGKkGa8tQBp5NIvHIt@mail.lidge.fr:587 ###< symfony/mailer ### diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 77c56dd..8f52699 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -138,6 +138,7 @@ class AdminController extends AbstractController $participant->setActif(false); $participant->setRoles(['ROLE_USER']); $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); + $participant->setPending(true); $entityManager->persist($participant); @@ -203,6 +204,7 @@ class AdminController extends AbstractController $participant->setActif(false); $participant->setRoles(explode('|', $row[7])); $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); + $participant->setPending(true); $em->persist($participant); // Générer un token unique From ab51562177ab5947019a92cea0fba12f977aa317 Mon Sep 17 00:00:00 2001 From: jleroy2023 Date: Mon, 25 Nov 2024 11:36:12 +0100 Subject: [PATCH 3/3] admin responsive V1 --- .env | 2 +- src/Controller/AdminController.php | 2 ++ templates/admin/index.html.twig | 5 ++--- templates/admin/sidebar.html.twig | 4 ++-- templates/main/footer.html.twig | 20 +++++--------------- 5 files changed, 12 insertions(+), 21 deletions(-) diff --git a/.env b/.env index cc08693..3c7998c 100644 --- a/.env +++ b/.env @@ -37,5 +37,5 @@ MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0 ###< symfony/messenger ### ###> symfony/mailer ### -MAILER_DSN=smtp:// +MAILER_DSN=smtp://dev-test@lidge.fr:N2uGKkGa8tQBp5NIvHIt@mail.lidge.fr:587 ###< symfony/mailer ### diff --git a/src/Controller/AdminController.php b/src/Controller/AdminController.php index 77c56dd..8f52699 100644 --- a/src/Controller/AdminController.php +++ b/src/Controller/AdminController.php @@ -138,6 +138,7 @@ class AdminController extends AbstractController $participant->setActif(false); $participant->setRoles(['ROLE_USER']); $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); + $participant->setPending(true); $entityManager->persist($participant); @@ -203,6 +204,7 @@ class AdminController extends AbstractController $participant->setActif(false); $participant->setRoles(explode('|', $row[7])); $participant->setPassword(password_hash("aChanger44!", PASSWORD_BCRYPT)); + $participant->setPending(true); $em->persist($participant); // Générer un token unique diff --git a/templates/admin/index.html.twig b/templates/admin/index.html.twig index d912f7d..ef0e495 100644 --- a/templates/admin/index.html.twig +++ b/templates/admin/index.html.twig @@ -3,11 +3,10 @@ {% block title %}📣 Sortie.com Admin 🔊{% endblock %} {% block content %} -
    - +
    {% include 'admin/sidebar.html.twig' %} -
    +

    Bienvenue sur le Panel d'Administration

    Utilisez le menu pour accéder aux différentes sections.

    diff --git a/templates/admin/sidebar.html.twig b/templates/admin/sidebar.html.twig index 4f8ae2b..099f60e 100644 --- a/templates/admin/sidebar.html.twig +++ b/templates/admin/sidebar.html.twig @@ -1,4 +1,4 @@ - diff --git a/templates/main/footer.html.twig b/templates/main/footer.html.twig index 28be863..19480b9 100644 --- a/templates/main/footer.html.twig +++ b/templates/main/footer.html.twig @@ -1,15 +1,5 @@ - - - - - {% block stylesheets %} - {{ encore_entry_link_tags('app') }} - {% endblock %} - - - -
    - ENI © Sortie {{ "now"|date("Y") }} -
    - - \ No newline at end of file + \ No newline at end of file