From 565e10c028660a4378cca225006c2656e9a84071 Mon Sep 17 00:00:00 2001 From: Marien Fressinaud Date: Wed, 20 Nov 2024 09:22:04 +0100 Subject: [PATCH] imp: Display the user organization automatically calculated --- src/Controller/UsersController.php | 4 ++++ templates/users/show.html.twig | 12 ++++++++---- translations/messages+intl-icu.en_GB.yaml | 2 ++ translations/messages+intl-icu.fr_FR.yaml | 2 ++ 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/Controller/UsersController.php b/src/Controller/UsersController.php index 4349ed0d..6720c606 100644 --- a/src/Controller/UsersController.php +++ b/src/Controller/UsersController.php @@ -61,9 +61,12 @@ public function show( Entity\User $user, Repository\AuthorizationRepository $authorizationRepository, Sorter\AuthorizationSorter $authorizationSorter, + Service\UserService $userService, ): Response { $this->denyAccessUnlessGranted('admin:manage:users'); + $defaultOrganization = $userService->getDefaultOrganization($user); + $authorizations = $authorizationRepository->findBy([ 'holder' => $user, ]); @@ -71,6 +74,7 @@ public function show( return $this->render('users/show.html.twig', [ 'user' => $user, + 'defaultOrganization' => $defaultOrganization, 'authorizations' => $authorizations, ]); } diff --git a/templates/users/show.html.twig b/templates/users/show.html.twig index 46216f5a..2a497aec 100644 --- a/templates/users/show.html.twig +++ b/templates/users/show.html.twig @@ -76,11 +76,15 @@

{% endif %} - {% if user.organization %} -

+

+ {% if user.organization %} {{ 'users.show.organization' | trans({ name: user.organization.name }) }} -

- {% endif %} + {% elseif defaultOrganization %} + {{ 'users.show.organization_automatic' | trans({ name: defaultOrganization.name }) }} + {% else %} + {{ 'users.show.no_organization' | trans }} + {% endif %} +

diff --git a/translations/messages+intl-icu.en_GB.yaml b/translations/messages+intl-icu.en_GB.yaml index 66500d18..5fc29886 100644 --- a/translations/messages+intl-icu.en_GB.yaml +++ b/translations/messages+intl-icu.en_GB.yaml @@ -550,6 +550,8 @@ users.show.edit: 'Edit the user' users.show.email: 'Email: {email}' users.show.ldap_identifier: 'LDAP identifier: {identifier}' users.show.name: 'Name: {name}' +users.show.no_organization: 'Organization: None' users.show.organization: 'Organization: {name}' +users.show.organization_automatic: 'Organization: {name} (automatic)' users.show.profile: 'User profile' users.yourself: yourself diff --git a/translations/messages+intl-icu.fr_FR.yaml b/translations/messages+intl-icu.fr_FR.yaml index 2c6d1310..3a6ef50e 100644 --- a/translations/messages+intl-icu.fr_FR.yaml +++ b/translations/messages+intl-icu.fr_FR.yaml @@ -550,6 +550,8 @@ users.show.edit: 'Modifier l’utilisateur' users.show.email: "Email\_: {email}" users.show.ldap_identifier: "Identifiant LDAP\_: {identifier}" users.show.name: "Nom\_: {name}" +users.show.no_organization: "Organisation\_: Aucune" users.show.organization: "Organisation\_: {name}" +users.show.organization_automatic: "Organisation\_: {name} (automatique)" users.show.profile: 'Profil utilisateur' users.yourself: vous