Skip to content

Commit

Permalink
Ajout de la page detail de l'autorité signataire (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarchois authored Nov 12, 2024
1 parent d44fabe commit 101be2f
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

declare(strict_types=1);

namespace App\Infrastructure\Controller\MyArea\Organization\SigningAuthority;

use App\Application\Organization\SigningAuthority\Query\GetSigningAuthorityByOrganizationQuery;
use App\Application\QueryBusInterface;
use App\Infrastructure\Controller\MyArea\Organization\AbstractOrganizationController;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Routing\Requirement\Requirement;

final class SigningAuthorityDetailController extends AbstractOrganizationController
{
public function __construct(
private \Twig\Environment $twig,
QueryBusInterface $queryBus,
Security $security,
) {
parent::__construct($queryBus, $security);
}

#[Route(
'/organizations/{uuid}/signing_authority',
name: 'app_config_signing_authority_detail',
requirements: ['uuid' => 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,
],
),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

declare(strict_types=1);

namespace App\Infrastructure\Persistence\Doctrine\Fixtures;

use App\Domain\Organization\SigningAuthority\SigningAuthority;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Persistence\ObjectManager;

final class SigningAuthorityFixture extends Fixture implements DependentFixtureInterface
{
public function load(ObjectManager $manager): void
{
$signatoryAuthority = new SigningAuthority(
uuid: '9cebe00d-04d8-48da-89b1-059f6b7bfe44',
name: 'Monsieur le maire de Savenay',
address: '3 rue de la Concertation',
placeOfSignature: 'Savenay',
signatoryName: 'Monsieur X, Maire de Savenay',
organization: $this->getReference('mainOrg'),
);

$manager->persist($signatoryAuthority);
$manager->flush();
}

public function getDependencies(): array
{
return [
OrganizationFixture::class,
];
}
}
2 changes: 1 addition & 1 deletion templates/my_area/organization/_menu.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</a>
</li>
<li class="fr-sidemenu__item">
<a class="fr-sidemenu__link" href="{{ path('app_config_signing_authority_edit', {uuid: organization.uuid}) }}" aria-current="{{ 'app_config_signing_authority_edit' in routeName ? 'true' : 'false' }}">
<a class="fr-sidemenu__link" href="{{ path('app_config_signing_authority_detail', {uuid: organization.uuid}) }}" aria-current="{{ 'app_config_signing_authority' in routeName ? 'true' : 'false' }}">
{{ 'config.menu.authority'|trans }}
</a>
</li>
Expand Down
42 changes: 42 additions & 0 deletions templates/my_area/organization/signing_authority/detail.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{% extends 'layouts/layout.html.twig' %}
{% set metaTitle = 'signing_authority.form.title'|trans %}
{% block title %}
{{ metaTitle }} - {{ parent() }}
{% endblock %}

{% block body %}
<section class="fr-container fr-py-5w">
<div class="fr-grid-row fr-grid-row--gutters">
<div class="fr-col-12 fr-col-md-4">
{% include 'my_area/organization/_menu.html.twig' with { organization } only %}
</div>
<div class="fr-col-12 fr-col-md-8">
{% include "common/breadcrumb.html.twig" with { items: [
{ title: 'user.myarea'|trans, path: 'app_my_area'},
{ title: metaTitle },
]} %}
<div class="fr-grid-row fr-x-gap-2w" data-testid="signing_authority">
<div class="fr-x-grow-32w">
<h2 class="fr-mb-0">{{ metaTitle }}</h2>
<p class="fr-my-2w fr-text--sm fr-message--info">
{{ 'signing_authority.help'|trans }}
</p>
<ul>
<li><b>{{ 'signing_authority.name'|trans }}</b> : {{ signingAuthority.name|default('N/D') }}</li>
<li><b>{{ 'signing_authority.address'|trans }}</b> : {{ signingAuthority.address|default('N/D') }}</li>
<li><b>{{ 'signing_authority.placeOfSignature'|trans }}</b> : {{ signingAuthority.placeOfSignature|default('N/D') }}</li>
<li><b>{{ 'signing_authority.signatoryName'|trans }}</b> : {{ signingAuthority.signatoryName|default('N/D') }}</li>
</ul>
</div>
<div class="fr-mb-3w">
{% if is_granted(constant('App\\Infrastructure\\Security\\Voter\\OrganizationVoter::EDIT'), organization) %}
<a href="{{ path('app_config_signing_authority_edit', { uuid: organization.uuid }) }}" class="fr-ml-auto fr-btn fr-btn--secondary fr-x-btn-sm--icon-left fr-icon-edit-line" title="{{ 'common.update'|trans }}">
{{ 'common.update'|trans }}
</a>
{% endif %}
</div>
</div>
</div>
</div>
</section>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace App\Tests\Integration\Infrastructure\Controller\MyArea\Organization\SigningAuthority;

use App\Infrastructure\Persistence\Doctrine\Fixtures\OrganizationFixture;
use App\Tests\Integration\Infrastructure\Controller\AbstractWebTestCase;

final class SigningAuthorityDetailControllerTest extends AbstractWebTestCase
{
public function testDetail(): void
{
$client = $this->login('[email protected]');
$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);
}
}
4 changes: 4 additions & 0 deletions translations/messages.fr.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -2524,6 +2524,10 @@
<source>signing_authority.name</source>
<target>Intitulé du signataire</target>
</trans-unit>
<trans-unit id="signing_authority.help">
<source>signing_authority.help</source>
<target>L'autorité signataire est gérée par les administrateurs de votre organisation. Si elle ne convient pas, contactez l’administrateur de votre organisation.</target>
</trans-unit>
<trans-unit id="signing_authority.name.help">
<source>signing_authority.name.help</source>
<target>Entrez l'intitulé du signataire, par exemple "Madame le maire de XX"</target>
Expand Down

0 comments on commit 101be2f

Please sign in to comment.