From e879c71ce7e1b8299567893e316b7624c08ce855 Mon Sep 17 00:00:00 2001 From: Dimitri Gritsajuk <gritsajuk.dimitri@gmail.com> Date: Thu, 30 Jan 2025 15:32:07 +0100 Subject: [PATCH] [ManagedUser] add delegated indicator to role --- features/api/adherents.feature | 40 ++++++++++++------------ features/api/profile.feature | 2 +- src/Entity/Projection/ManagedUser.php | 1 + src/Normalizer/ManagedUserNormalizer.php | 6 +++- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/features/api/adherents.feature b/features/api/adherents.feature index 1c7118202c2..4e03ff4333a 100644 --- a/features/api/adherents.feature +++ b/features/api/adherents.feature @@ -140,7 +140,7 @@ Feature: "tags": [ { "type": "role", - "label": "Président assemblée départementale", + "label": "Président assemblée départementale délégué", "tooltip": "Responsable communication" } ], @@ -197,47 +197,47 @@ Feature: }, { "type": "role", - "label": "Délégué de circonscription", + "label": "Délégué de circonscription délégué", "tooltip": "Collaborateur parlementaire" }, { "type": "role", - "label": "Sénateur", + "label": "Sénateur délégué", "tooltip": "Collaborateur parlementaire" }, { "type": "role", - "label": "Délégué de circonscription", + "label": "Délégué de circonscription délégué", "tooltip": "Collaborateur parlementaire" }, { "type": "role", - "label": "Candidat", + "label": "Candidat délégué", "tooltip": "Candidat délégué" }, { "type": "role", - "label": "Candidat Sénatoriales 2020", + "label": "Candidat Sénatoriales 2020 délégué", "tooltip": "Candidat Sénateur délégué" }, { "type": "role", - "label": "Président assemblée départementale", + "label": "Président assemblée départementale délégué", "tooltip": "Responsable élus délégué #1" }, { "type": "role", - "label": "Président assemblée départementale", + "label": "Président assemblée départementale délégué", "tooltip": "Responsable communication" }, { "type": "role", - "label": "Responsable local", + "label": "Responsable local délégué", "tooltip": "Responsable logistique" }, { "type": "role", - "label": "Candidat aux législatives", + "label": "Candidat aux législatives délégué", "tooltip": "Responsable communication" }, { @@ -374,47 +374,47 @@ Feature: }, { "type": "role", - "label": "Délégué de circonscription", + "label": "Délégué de circonscription délégué", "tooltip": "Collaborateur parlementaire" }, { "type": "role", - "label": "Sénateur", + "label": "Sénateur délégué", "tooltip": "Collaborateur parlementaire" }, { "type": "role", - "label": "Délégué de circonscription", + "label": "Délégué de circonscription délégué", "tooltip": "Collaborateur parlementaire" }, { "type": "role", - "label": "Candidat", + "label": "Candidat délégué", "tooltip": "Candidat délégué" }, { "type": "role", - "label": "Candidat Sénatoriales 2020", + "label": "Candidat Sénatoriales 2020 délégué", "tooltip": "Candidat Sénateur délégué" }, { "type": "role", - "label": "Président assemblée départementale", + "label": "Président assemblée départementale délégué", "tooltip": "Responsable élus délégué #1" }, { "type": "role", - "label": "Président assemblée départementale", + "label": "Président assemblée départementale délégué", "tooltip": "Responsable communication" }, { "type": "role", - "label": "Responsable local", + "label": "Responsable local délégué", "tooltip": "Responsable logistique" }, { "type": "role", - "label": "Candidat aux législatives", + "label": "Candidat aux législatives délégué", "tooltip": "Responsable communication" }, { @@ -477,7 +477,7 @@ Feature: "tags": [ { "type": "role", - "label": "Président assemblée départementale", + "label": "Président assemblée départementale délégué", "tooltip": "Responsable communication" } ], diff --git a/features/api/profile.feature b/features/api/profile.feature index 368c559478e..94d276c98e0 100644 --- a/features/api/profile.feature +++ b/features/api/profile.feature @@ -1679,7 +1679,7 @@ Feature: Scenario: As a logged-in user with new app version I can not unregister with empty body Given I am logged with "michelle.dufour@example.ch" via OAuth client "JeMengage Mobile" - And I add "X-App-Version" header equal to "v5.11.0" + And I add "X-App-Version" header equal to "v5.18.0#0" When I send a "POST" request to "/api/v3/profile/unregister" Then the response status code should be 400 diff --git a/src/Entity/Projection/ManagedUser.php b/src/Entity/Projection/ManagedUser.php index e928ff2f218..d68a904f1b6 100644 --- a/src/Entity/Projection/ManagedUser.php +++ b/src/Entity/Projection/ManagedUser.php @@ -607,6 +607,7 @@ public function getRolesAsArray(): array $rolePart = explode('|', $role); $roleData['role'] = $rolePart[0]; + $roleData['is_delegated'] = true; $roleData['function'] = $rolePart[1]; } $roles[] = $roleData; diff --git a/src/Normalizer/ManagedUserNormalizer.php b/src/Normalizer/ManagedUserNormalizer.php index e09da1abea7..55f1ab560ee 100644 --- a/src/Normalizer/ManagedUserNormalizer.php +++ b/src/Normalizer/ManagedUserNormalizer.php @@ -47,7 +47,11 @@ public function normalize($object, $format = null, array $context = []): array|s function (array $role) { return [ 'type' => 'role', - 'label' => ($label = $this->translator->trans($key = 'role.'.$role['role'])) === $key ? $role['role'] : $label, + 'label' => \sprintf( + '%s%s', + ($label = $this->translator->trans($key = 'role.'.$role['role'])) === $key ? $role['role'] : $label, + !empty($role['is_delegated']) ? ' délégué' : '' + ), 'tooltip' => $role['function'] ?? null, ]; },