From 668a2a3dffe09a2f797d6715ee19f3d5d977ea4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gardien?= Date: Wed, 30 Oct 2024 09:59:38 +0100 Subject: [PATCH] [Admin] Add action to refresh adherent tags --- config/packages/security.yaml | 1 + src/Admin/AdherentAdmin.php | 6 ++++++ .../Admin/AdminAdherentCRUDController.php | 15 +++++++++++++++ .../adherent/action_button_refresh_tags.html.twig | 5 +++++ 4 files changed, 27 insertions(+) create mode 100644 templates/admin/adherent/action_button_refresh_tags.html.twig diff --git a/config/packages/security.yaml b/config/packages/security.yaml index a281e475c9c..e3b35610ed5 100644 --- a/config/packages/security.yaml +++ b/config/packages/security.yaml @@ -57,6 +57,7 @@ security: - ROLE_APP_ADMIN_DISTRICT_LIST - ROLE_APP_ADMIN_ADHERENT_ZONE_BASED_ROLE_ADMIN_ALL - ROLE_APP_ADMIN_POLITICAL_COMMITTEE_ALL + - ROLE_APP_ADMIN_ADHERENT_REFRESH_TAGS ROLE_ADMIN_STATS_ALL: - ROLE_ADMIN_ADHERENT_STATS - ROLE_ADMIN_PROCURATION_STATS diff --git a/src/Admin/AdherentAdmin.php b/src/Admin/AdherentAdmin.php index 42c89863bdc..49689336e38 100644 --- a/src/Admin/AdherentAdmin.php +++ b/src/Admin/AdherentAdmin.php @@ -22,6 +22,7 @@ protected function getAccessMapping(): array 'extract' => 'EXTRACT', 'create_renaissance' => 'CREATE_RENAISSANCE', 'create_renaissance_verify_email' => 'CREATE_RENAISSANCE_VERIFY_EMAIL', + 'refresh_tags' => 'REFRESH_TAGS', ]; } @@ -38,6 +39,7 @@ protected function configureRoutes(RouteCollectionInterface $collection): void ->add('send_resubscribe_email', $this->getRouterIdParameter().'/send-resubscribe-email') ->add('create_renaissance', 'create-renaissance') ->add('create_renaissance_verify_email', 'create-adherent-verify-email') + ->add('refresh_tags', $this->getRouterIdParameter().'/refresh-tags') ; } @@ -69,6 +71,10 @@ protected function configureActionButtons(array $buttonList, string $action, ?ob if ($this->hasAccess('uncertify', $object) && $this->hasRoute('uncertify')) { $actions['uncertify'] = ['template' => 'admin/adherent/action_button_uncertify.html.twig']; } + + if ($this->hasAccess('refresh_tags', $object) && $this->hasRoute('refresh_tags')) { + $actions['refresh_tags'] = ['template' => 'admin/adherent/action_button_refresh_tags.html.twig']; + } } $actions['extract'] = ['template' => 'admin/adherent/extract/extract_button.html.twig']; diff --git a/src/Controller/Admin/AdminAdherentCRUDController.php b/src/Controller/Admin/AdminAdherentCRUDController.php index 718afa4c19f..d0c859bd859 100644 --- a/src/Controller/Admin/AdminAdherentCRUDController.php +++ b/src/Controller/Admin/AdminAdherentCRUDController.php @@ -8,6 +8,7 @@ use App\Adherent\Certification\CertificationAuthorityManager; use App\Adherent\Certification\CertificationPermissions; use App\Adherent\Command\SendResubscribeEmailCommand; +use App\Adherent\Tag\Command\RefreshAdherentTagCommand; use App\Adherent\UnregistrationManager; use App\Entity\Adherent; use App\Form\Admin\Adherent\CreateRenaissanceType; @@ -28,6 +29,20 @@ public function __construct(private readonly AdherentRepository $adherentReposit { } + public function refreshTagsAction(Request $request, MessageBusInterface $bus): Response + { + /** @var Adherent $adherent */ + $adherent = $this->admin->getSubject(); + + $this->admin->checkAccess('refresh_tags', $adherent); + + $bus->dispatch(new RefreshAdherentTagCommand($adherent->getUuid())); + + $this->addFlash('success', 'Les tags ont été rafraichis avec succès.'); + + return $this->redirectTo($request, $adherent); + } + public function banAction(Request $request, BanManager $adherentManagementAuthority): Response { $adherent = $this->admin->getSubject(); diff --git a/templates/admin/adherent/action_button_refresh_tags.html.twig b/templates/admin/adherent/action_button_refresh_tags.html.twig new file mode 100644 index 00000000000..c15f6c4fa97 --- /dev/null +++ b/templates/admin/adherent/action_button_refresh_tags.html.twig @@ -0,0 +1,5 @@ +
  • + + Rafraîchir les tags + +