From 101be2f90b9651a2b18241bf37566c8a482877ed Mon Sep 17 00:00:00 2001 From: Mathieu MARCHOIS Date: Tue, 12 Nov 2024 16:51:29 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20de=20la=20page=20detail=20de=20l'autori?= =?UTF-8?q?t=C3=A9=20signataire=20(#1067)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../EditSigningAuthorityController.php | 2 +- .../SigningAuthorityDetailController.php | 46 ++++++++++++++++ .../Fixtures/SigningAuthorityFixture.php | 35 +++++++++++++ .../my_area/organization/_menu.html.twig | 2 +- .../signing_authority/detail.html.twig | 42 +++++++++++++++ .../EditSigningAuthorityControllerTest.php | 2 +- .../SigningAuthorityDetailControllerTest.php | 52 +++++++++++++++++++ translations/messages.fr.xlf | 4 ++ 8 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailController.php create mode 100644 src/Infrastructure/Persistence/Doctrine/Fixtures/SigningAuthorityFixture.php create mode 100644 templates/my_area/organization/signing_authority/detail.html.twig create mode 100644 tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailControllerTest.php diff --git a/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityController.php b/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityController.php index 5fe9ff4a2..09c37fd81 100644 --- a/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityController.php +++ b/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityController.php @@ -57,7 +57,7 @@ public function __invoke(Request $request, string $uuid): Response $this->commandBus->handle($command); return new RedirectResponse( - url: $this->router->generate('app_config_signing_authority_edit', ['uuid' => $uuid]), + url: $this->router->generate('app_config_signing_authority_detail', ['uuid' => $uuid]), status: Response::HTTP_SEE_OTHER, ); } diff --git a/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailController.php b/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailController.php new file mode 100644 index 000000000..7ebe48823 --- /dev/null +++ b/src/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailController.php @@ -0,0 +1,46 @@ + Requirement::UUID], + methods: ['GET'], + )] + public function __invoke(string $uuid): Response + { + $signingAuthority = $this->queryBus->handle(new GetSigningAuthorityByOrganizationQuery($uuid)); + $organization = $this->getOrganization($uuid); + + return new Response( + content: $this->twig->render( + name: 'my_area/organization/signing_authority/detail.html.twig', + context: [ + 'signingAuthority' => $signingAuthority, + 'organization' => $organization, + ], + ), + ); + } +} diff --git a/src/Infrastructure/Persistence/Doctrine/Fixtures/SigningAuthorityFixture.php b/src/Infrastructure/Persistence/Doctrine/Fixtures/SigningAuthorityFixture.php new file mode 100644 index 000000000..3a2f15441 --- /dev/null +++ b/src/Infrastructure/Persistence/Doctrine/Fixtures/SigningAuthorityFixture.php @@ -0,0 +1,35 @@ +getReference('mainOrg'), + ); + + $manager->persist($signatoryAuthority); + $manager->flush(); + } + + public function getDependencies(): array + { + return [ + OrganizationFixture::class, + ]; + } +} diff --git a/templates/my_area/organization/_menu.html.twig b/templates/my_area/organization/_menu.html.twig index d618aa285..b51901657 100644 --- a/templates/my_area/organization/_menu.html.twig +++ b/templates/my_area/organization/_menu.html.twig @@ -26,7 +26,7 @@
  • - + {{ 'config.menu.authority'|trans }}
  • diff --git a/templates/my_area/organization/signing_authority/detail.html.twig b/templates/my_area/organization/signing_authority/detail.html.twig new file mode 100644 index 000000000..5eec39f62 --- /dev/null +++ b/templates/my_area/organization/signing_authority/detail.html.twig @@ -0,0 +1,42 @@ +{% extends 'layouts/layout.html.twig' %} +{% set metaTitle = 'signing_authority.form.title'|trans %} +{% block title %} + {{ metaTitle }} - {{ parent() }} +{% endblock %} + +{% block body %} +
    +
    +
    + {% include 'my_area/organization/_menu.html.twig' with { organization } only %} +
    +
    + {% include "common/breadcrumb.html.twig" with { items: [ + { title: 'user.myarea'|trans, path: 'app_my_area'}, + { title: metaTitle }, + ]} %} +
    +
    +

    {{ metaTitle }}

    +

    + {{ 'signing_authority.help'|trans }} +

    +
      +
    • {{ 'signing_authority.name'|trans }} : {{ signingAuthority.name|default('N/D') }}
    • +
    • {{ 'signing_authority.address'|trans }} : {{ signingAuthority.address|default('N/D') }}
    • +
    • {{ 'signing_authority.placeOfSignature'|trans }} : {{ signingAuthority.placeOfSignature|default('N/D') }}
    • +
    • {{ 'signing_authority.signatoryName'|trans }} : {{ signingAuthority.signatoryName|default('N/D') }}
    • +
    +
    +
    + {% if is_granted(constant('App\\Infrastructure\\Security\\Voter\\OrganizationVoter::EDIT'), organization) %} + + {{ 'common.update'|trans }} + + {% endif %} +
    +
    +
    +
    +
    +{% endblock %} diff --git a/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityControllerTest.php b/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityControllerTest.php index ab5d6309f..59dfaa2cd 100644 --- a/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityControllerTest.php +++ b/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/EditSigningAuthorityControllerTest.php @@ -33,7 +33,7 @@ public function testEdit(): void $client->followRedirect(); $this->assertResponseStatusCodeSame(200); - $this->assertRouteSame('app_config_signing_authority_edit'); + $this->assertRouteSame('app_config_signing_authority_detail'); } public function testBadFormValues(): void diff --git a/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailControllerTest.php b/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailControllerTest.php new file mode 100644 index 000000000..3d1f7fef9 --- /dev/null +++ b/tests/Integration/Infrastructure/Controller/MyArea/Organization/SigningAuthority/SigningAuthorityDetailControllerTest.php @@ -0,0 +1,52 @@ +login('mathieu.fernandez@beta.gouv.fr'); + $crawler = $client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::MAIN_ORG_ID . '/signing_authority'); + + $this->assertResponseStatusCodeSame(200); + $this->assertSecurityHeaders(); + $this->assertSame('Autorité signataire', $crawler->filter('h2')->text()); + $this->assertMetaTitle('Autorité signataire - DiaLog', $crawler); + + $this->assertSame($crawler->filter('[data-testid="signing_authority"] ul')->text(), 'Intitulé du signataire : Monsieur le maire de Savenay Adresse de l\'établissement : 3 rue de la Concertation Fait à : Savenay Nom du signataire : Monsieur X, Maire de Savenay'); + } + + public function testNotAdministrator(): void + { + $client = $this->login(); + $client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::MAIN_ORG_ID . '/signing_authority'); + $this->assertResponseStatusCodeSame(200); + } + + public function testOrganizationNotOwned(): void + { + $client = $this->login(); + $client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::OTHER_ORG_ID . '/signing_authority'); + $this->assertResponseStatusCodeSame(403); + } + + public function testOrganizationOrUserNotFound(): void + { + $client = $this->login(); + $client->request('GET', '/mon-espace/organizations/f5c1cea8-a61d-43a7-9b5d-4b8c9557c673/signing_authority'); + $this->assertResponseStatusCodeSame(404); + } + + public function testWithoutAuthenticatedUser(): void + { + $client = static::createClient(); + $client->request('GET', '/mon-espace/organizations/' . OrganizationFixture::MAIN_ORG_ID . '/signing_authority'); + $this->assertResponseRedirects('http://localhost/login', 302); + } +} diff --git a/translations/messages.fr.xlf b/translations/messages.fr.xlf index 3847e157c..08787bcdd 100644 --- a/translations/messages.fr.xlf +++ b/translations/messages.fr.xlf @@ -2524,6 +2524,10 @@ signing_authority.name Intitulé du signataire + + signing_authority.help + L'autorité signataire est gérée par les administrateurs de votre organisation. Si elle ne convient pas, contactez l’administrateur de votre organisation. + signing_authority.name.help Entrez l'intitulé du signataire, par exemple "Madame le maire de XX"