Skip to content

Commit

Permalink
Merge pull request #3240 from MTES-MCT/feature/3236-active-histo-affe…
Browse files Browse the repository at this point in the history
…ctation-for-user

[BO - Signalement - Historique affectation] Afficher le bouton pour tous les users avec les droits d'affectation
  • Loading branch information
sfinx13 authored Oct 31, 2024
2 parents b57739b + 8a585a3 commit 8eb38b1
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion cron.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"command": "0 0 * * * sh /app/scripts/clean.sh"
},
{
"command": "15 1-5 * * * php bin/console app:clear-storage-original-file"
"command": "0 2 */5 * * php bin/console app:clear-storage-original-file"
},
{
"command": "0 6 * * * php bin/console app:ask-feedback-usager"
Expand Down
12 changes: 5 additions & 7 deletions src/Controller/Back/HistoryEntryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\Security\Http\Attribute\IsGranted;

#[Route('/bo/history')]
class HistoryEntryController extends AbstractController
Expand All @@ -24,19 +23,18 @@ public function __construct(
}

#[Route('/signalement/{id}/affectations', name: 'history_affectation', methods: ['GET'])]
#[IsGranted('ROLE_ADMIN_TERRITORY')]
public function listHistoryAffectation(
Request $request,
HistoryEntryManager $historyEntryManager,
SignalementRepository $signalementRepository,
): Response {
$signalement = $signalementRepository->find($request->get('id'));
if ($signalement && $this->isGranted('SIGN_VIEW', $signalement)) {
$historyEntries = $historyEntryManager->getAffectationHistory($signalement->getId());

return $this->json(['historyEntries' => $historyEntries]);
if (!$signalement || !$this->isGranted('SIGN_VIEW', $signalement) || !$this->isGranted('ASSIGN_TOGGLE', $signalement)) {
return $this->json(['response' => 'error'], Response::HTTP_FORBIDDEN);
}

return $this->json(['response' => 'error'], 400);
$historyEntries = $historyEntryManager->getAffectationHistory($signalement->getId());

return $this->json(['historyEntries' => $historyEntries]);
}
}
2 changes: 1 addition & 1 deletion templates/back/signalement/view.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
{% block content %}
{% if not needValidation and (is_granted('ROLE_ADMIN_TERRITORY') or canPartnerAffectation) %}
{% include '_partials/_modal_affectation.html.twig' %}
{% if platform.feature_historique_affectations and is_granted('ROLE_ADMIN_TERRITORY') %}
{% if (platform.feature_historique_affectations and is_granted('ROLE_ADMIN_TERRITORY')) or canPartnerAffectation %}
{% include '_partials/_modal_historique_affectation.html.twig' %}
{% endif %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion templates/back/signalement/view/partners.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>
<div class="fr-col-3 fr-col-md-6">
<div class="fr-text--right fr-btns-group fr-btns-group--sm fr-btns-group--inline fr-btns-group--right fr-btns-group--icon-left">
{% if platform.feature_historique_affectations and is_granted('ROLE_ADMIN_TERRITORY') %}
{% if (platform.feature_historique_affectations and is_granted('ROLE_ADMIN_TERRITORY')) or canPartnerAffectation %}
<button
class="fr-btn fr-btn--secondary fr-btn--icon-left"
data-fr-opened="false"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testListHistoryAffectationWithoutSignalementId()
]);
$this->client->request('GET', $route);

$this->assertResponseStatusCodeSame(400);
$this->assertResponseStatusCodeSame(403);

$this->assertJson($this->client->getResponse()->getContent());
$response = json_decode($this->client->getResponse()->getContent(), true);
Expand Down

0 comments on commit 8eb38b1

Please sign in to comment.