From 0beb0cd95f6a6d41da53c79303dd160f9ac1d3b4 Mon Sep 17 00:00:00 2001 From: Bastien OLLIER Date: Thu, 13 Jun 2024 09:30:25 +0200 Subject: [PATCH] Update interface (#17) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: bastien ollier Reviewed-on: https://codefirst.iut.uca.fr/git/clement.freville2/herbarium/pulls/17 Reviewed-by: Clément FRÉVILLE Co-authored-by: Bastien OLLIER Co-committed-by: Bastien OLLIER --- src/Controller/PostController.php | 17 +++++++--------- src/Controller/SpeciesController.php | 2 +- templates/base.html.twig | 23 +++++++++++++++++++++- templates/post/edit.html.twig | 2 +- templates/post/new.html.twig | 2 +- templates/post/show.html.twig | 4 ++-- templates/post/table.html.twig | 2 +- templates/species/_form.html.twig | 2 +- templates/species/edit.html.twig | 2 +- templates/species/new.html.twig | 2 +- templates/species/show.html.twig | 4 ++-- tests/Controller/PostControllerTest.php | 6 +++--- tests/Controller/SpeciesControllerTest.php | 2 +- translations/messages.fr.xlf | 2 +- 14 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/Controller/PostController.php b/src/Controller/PostController.php index af3d395..7f4e77f 100644 --- a/src/Controller/PostController.php +++ b/src/Controller/PostController.php @@ -34,16 +34,13 @@ class PostController extends AbstractController ]); } - #[Route('/post', name: 'app_post_index', methods: ['GET'])] + #[Route('/posts', name: 'app_post_index', methods: ['GET'])] public function table(PostRepository $repository): Response { - $posts = $repository->findAll(); - return $this->render('post/table.html.twig', [ - 'posts' => $posts, - ]); + return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER); } - #[Route('/post/new', name: 'app_post_new', methods: ['GET', 'POST'])] + #[Route('/posts/new', name: 'app_post_new', methods: ['GET', 'POST'])] #[IsGranted('ROLE_USER')] public function new(Request $request, EntityManagerInterface $entityManager): Response { @@ -64,7 +61,7 @@ class PostController extends AbstractController ]); } - #[Route('/post/{id}', name: 'app_post_show', methods: ['GET'])] + #[Route('/posts/{id}', name: 'app_post_show', methods: ['GET'])] public function show(Post $post): Response { $form = $this->createForm(CommentType::class, new Comment(), [ @@ -76,7 +73,7 @@ class PostController extends AbstractController ]); } - #[Route('/post/{id}/edit', name: 'app_post_edit', methods: ['GET', 'POST'])] + #[Route('/posts/{id}/edit', name: 'app_post_edit', methods: ['GET', 'POST'])] #[IsGranted('ROLE_USER')] public function edit(Request $request, Post $post, EntityManagerInterface $entityManager): Response { @@ -95,7 +92,7 @@ class PostController extends AbstractController ]); } - #[Route('/post/{id}', name: 'app_post_delete', methods: ['POST'])] + #[Route('/posts/{id}', name: 'app_post_delete', methods: ['POST'])] #[IsGranted('ROLE_USER')] public function delete(Request $request, Post $post, EntityManagerInterface $entityManager): Response { @@ -107,7 +104,7 @@ class PostController extends AbstractController return $this->redirectToRoute('app_posts', [], Response::HTTP_SEE_OTHER); } - #[Route('/post/{id}/comment', name: 'app_post_comment', methods: ['POST'])] + #[Route('/posts/{id}/comment', name: 'app_post_comment', methods: ['POST'])] public function publishComment(Request $request, Post $post, EntityManagerInterface $entityManager, #[CurrentUser] User $user): Response { $comment = new Comment(); diff --git a/src/Controller/SpeciesController.php b/src/Controller/SpeciesController.php index a495a0f..4af751c 100644 --- a/src/Controller/SpeciesController.php +++ b/src/Controller/SpeciesController.php @@ -18,7 +18,7 @@ class SpeciesController extends AbstractController #[Route('/', name: 'app_species_index', methods: ['GET'])] public function table(SpeciesRepository $speciesRepository): Response { - return $this->render('species/table.html.twig', [ + return $this->render('species/index.html.twig', [ 'species' => $speciesRepository->findAll(), ]); } diff --git a/templates/base.html.twig b/templates/base.html.twig index 4f29e24..0ced7a9 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -15,7 +15,28 @@