Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
pierrelemee committed Jan 13, 2025
2 parents 55fb9d9 + 8a3d966 commit c98c679
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/Controller/Agent/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MonIndemnisationJustice\Entity\Requerant;
use Doctrine\ORM\EntityManagerInterface;
use League\Flysystem\FilesystemOperator;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\Attribute\Target;
use Symfony\Component\HttpFoundation\File\UploadedFile;
Expand All @@ -19,7 +20,7 @@
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[IsGranted(Agent::ROLE_AGENT_REDACTEUR)]
//#[IsGranted(Agent::ROLE_AGENT_REDACTEUR)]
#[Route('/agent/document')]
class DocumentController extends AbstractController
{
Expand All @@ -29,12 +30,13 @@ public function __construct(
) {
}

#[Route('/{id}/{filename}', name: 'agent_document_download', methods: ['GET'])]
public function download(Document $document, string $filename): Response
#[Route('/{id}/{hash}', name: 'agent_document_download', methods: ['GET'])]
public function download(#[MapEntity(id: 'id')] Document $document, string $hash): Response
{
if ($document->getFilename() !== $filename) {
if (md5($document->getFilename()) !== $hash) {
throw new NotFoundHttpException('Document non trouvé');
}

$stream = $this->storage->readStream($document->getFilename());

return new StreamedResponse(
Expand Down
3 changes: 2 additions & 1 deletion src/Controller/Agent/RedacteurController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use MonIndemnisationJustice\Entity\BrisPorte;
use MonIndemnisationJustice\Entity\EtatDossierType;
use MonIndemnisationJustice\Repository\BrisPorteRepository;
use Symfony\Bridge\Doctrine\Attribute\MapEntity;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -42,7 +43,7 @@ public function nouveauxDossiers(): Response
}

#[Route('/dossier/{id}/consulter', name: 'agent_bris_porte_consulter', methods: ['GET'])]
public function consulter(BrisPorte $dossier): Response
public function consulter(#[MapEntity(id: 'id')] BrisPorte $dossier): Response
{
return $this->render('agent/redacteur/consulter_bris_porte.html.twig', [
'dossier' => $dossier,
Expand Down
1 change: 1 addition & 0 deletions src/Twig/AppExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public function getFilters(): array
new TwigFilter('spellout', [AppRuntime::class, 'spellout']),
new TwigFilter('est_agent', [AppRuntime::class, 'estAgent']),
new TwigFilter('est_requerant', [AppRuntime::class, 'estRequerant']),
new TwigFilter('md5', 'md5'),
new TwigFilter('base64_encode', 'base64_encode'),
new TwigFilter('base64_decode', 'base64_decode'),
new TwigFilter('to_snake', [AppRuntime::class, 'toSnake']),
Expand Down
4 changes: 2 additions & 2 deletions templates/agent/redacteur/consulter_bris_porte.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@
<div class="fr-grid-row">
<h6>{{ document.originalFilename }}</h6>
{% if document.mime == 'application/pdf' %}
<object data="{{ url('agent_document_download', {'id': document.id, 'filename': document.filename }) }}" type="application/pdf" style="width:100%;aspect-ratio: 210/297;" ></object>
<object data="{{ url('agent_document_download', {'id': document.id, 'hash': document.filename|md5 }) }}" type="application/pdf" style="width:100%;aspect-ratio: 210/297;" ></object>
{% else %}
<img src="{{ url('agent_document_download', {'id': document.id, 'filename': document.filename }) }}" style="width:100%;max-height: 100vh;" />
<img src="{{ url('agent_document_download', {'id': document.id, 'hash': document.filename|md5 }) }}" style="width:100%;max-height: 100vh;" />
{% endif %}
</div>
{% endfor %}
Expand Down

0 comments on commit c98c679

Please sign in to comment.