Skip to content

Commit

Permalink
[Admin] Add action to refresh adherent tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Remg committed Oct 30, 2024
1 parent 10e60e4 commit 668a2a3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/Admin/AdherentAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
];
}

Expand All @@ -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')
;
}

Expand Down Expand Up @@ -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'];
Expand Down
15 changes: 15 additions & 0 deletions src/Controller/Admin/AdminAdherentCRUDController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
Expand Down
5 changes: 5 additions & 0 deletions templates/admin/adherent/action_button_refresh_tags.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<li>
<a href="{{ admin.generateObjectUrl('refresh_tags', object) }}" class="sonata-action-element" title="Rafraîchissement des tags">
<i class="fa fa-refresh"></i> Rafraîchir les tags
</a>
</li>

0 comments on commit 668a2a3

Please sign in to comment.