From ce5af04df7359c449c7e8374e62fc0b69ca19cad Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 18 Nov 2021 14:46:33 +0100 Subject: [PATCH 1/8] closed step added + form/controller/template basic start --- .../AccompanyingCourseController.php | 25 +++++++++++++++++ .../ChillPersonExtension.php | 5 ++++ .../Entity/AccompanyingPeriod.php | 11 ++++++++ .../Form/AccompanyingCourseType.php | 22 +++++++++++++++ .../views/AccompanyingCourse/close.html.twig | 28 +++++++++++++++++++ 5 files changed, 91 insertions(+) create mode 100644 src/Bundle/ChillPersonBundle/Form/AccompanyingCourseType.php create mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/close.html.twig diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 5c11f4802..3b6698875 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -158,4 +158,29 @@ class AccompanyingCourseController extends Controller ]); } + /** + * @Route("/{_locale}/parcours/{accompanying_period_id}/close", name="chill_person_accompanying_course_close") + * @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"}) + */ + + public function closeAction(AccompanyingPeriod $accompanyingCourse, Request $request): Response + { + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $accompanyingCourse); + + $form = $this->createForm(AccompanyingCourseType::class, $accompanyingCourse); + + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + + $this->getDoctrine()->getManager()->flush(); + + } + + return $this->render('@ChillPerson/AccompanyingCourse/close.html.twig', [ + 'form' => $form->createView(), + 'accompanyingCourse' => $accompanyingCourse + ]); + } + } diff --git a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php index 211765330..996215082 100644 --- a/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php +++ b/src/Bundle/ChillPersonBundle/DependencyInjection/ChillPersonExtension.php @@ -221,12 +221,17 @@ class ChillPersonExtension extends Extension implements PrependExtensionInterfac 'places' => [ 'DRAFT', 'CONFIRMED', + 'CLOSED', ], 'transitions' => [ 'confirm' => [ 'from' => 'DRAFT', 'to' => 'CONFIRMED' ], + 'close' => [ + 'from' => 'CONFIRMED', + 'to' => 'CLOSED' + ], ], ], ] diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 15f33abe7..0fdbe35fd 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -94,6 +94,14 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface */ public const STEP_CONFIRMED = 'CONFIRMED'; + /** + * Mark an accompanying period as "closed". + * + * This means that the accompanying period **is** + * closed by the creator + */ + public const STEP_CLOSED = 'CLOSED'; + /** * @var integer * @@ -117,6 +125,8 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface * * @ORM\Column(type="date", nullable=true) * @Groups({"read", "write"}) + * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED}) + * @Assert\GreaterThan(propertyPath="openingDate", groups={AccompanyingPeriod::STEP_CLOSED}) */ private $closingDate = null; @@ -166,6 +176,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface * targetEntity="Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive") * @ORM\JoinColumn(nullable=true) * @Groups({"read", "write"}) + * @Assert\NotBlank(groups={AccompanyingPeriod::STEP_CLOSED}) */ private $closingMotive = null; diff --git a/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseType.php b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseType.php new file mode 100644 index 000000000..a1bdd5c2e --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Form/AccompanyingCourseType.php @@ -0,0 +1,22 @@ +add('closingDate', ChillDateType::class, + [ + 'required' => true, + ]); + + $builder->add('closingMotive', ClosingMotivePickerType::class); + } +} \ No newline at end of file diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/close.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/close.html.twig new file mode 100644 index 000000000..f0c819b35 --- /dev/null +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/close.html.twig @@ -0,0 +1,28 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% block content %} +

{{ "Close accompanying course"|trans }}

+ + {{ form_start(form) }} + + {{ form_row(form.closingDate) }} + {{ form_row(form.closingMotive) }} + + {% set accompanying_course_id = null %} + {% if accompanyingCourse %} + {% set accompanying_course_id = accompanyingCourse.id %} + {% endif %} + + + + {{ form_end(form) }} +{% endblock %} \ No newline at end of file From 6db180e7ca766dabc69c596493e9feb0ef47e318 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 18 Nov 2021 14:56:59 +0100 Subject: [PATCH 2/8] use statement fix --- .../Controller/AccompanyingCourseController.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 3b6698875..1f4262034 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -7,6 +7,7 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation; use Chill\PersonBundle\Privacy\AccompanyingPeriodPrivacyEvent; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Form\AccompanyingCourseType; use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter; From dcbed94050d63814af495b74bf72bb641b102cd8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 18 Nov 2021 15:01:03 +0100 Subject: [PATCH 3/8] changelog updated --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 31c3e1b5d..a7e354584 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ and this project adheres to * [person] do not ask for center any more on person creation * [3party] do not ask for center any more on 3party creation * [task] Select2 field in task form to allow search for a user (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/167) +* [accompanyingCourse] Ability to close accompanying course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/296) ## Test releases From 6c48a22f8673e19c2b0fcdb7b5cb6f2a4809d85e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Nov 2021 08:37:56 +0100 Subject: [PATCH 4/8] transition added + attempt voter --- .../Controller/AccompanyingCourseController.php | 12 +++++++++++- .../Authorization/AccompanyingPeriodVoter.php | 6 ++++++ .../config/services/controller.yaml | 7 ++----- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 1f4262034..c9b9cee35 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -23,6 +23,7 @@ use Symfony\Component\Serializer\SerializerInterface; use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Validator\Validator\ValidatorInterface; +use Symfony\Component\Workflow\Registry; /** * Class AccompanyingCourseController @@ -39,16 +40,20 @@ class AccompanyingCourseController extends Controller private AccompanyingPeriodWorkRepository $workRepository; + private Registry $registry; + public function __construct( SerializerInterface $serializer, EventDispatcherInterface $dispatcher, ValidatorInterface $validator, - AccompanyingPeriodWorkRepository $workRepository + AccompanyingPeriodWorkRepository $workRepository, + Registry $registry ) { $this->serializer = $serializer; $this->dispatcher = $dispatcher; $this->validator = $validator; $this->workRepository = $workRepository; + $this->registry = $registry; } /** @@ -175,6 +180,11 @@ class AccompanyingCourseController extends Controller if ($form->isSubmitted() && $form->isValid()) { $this->getDoctrine()->getManager()->flush(); + $workflow = $this->registry->get($accompanyingCourse); + + if ($workflow->can($accompanyingCourse, 'close')) { + $workflow->apply($accompanyingCourse, 'close'); + } } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 5247df505..49847d114 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -78,6 +78,12 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole return false; } + if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { + if($this->security->isGranted(self::EDIT, $subject)) { + return false; + } + } + // if confidential, only the referent can see it if ($subject->isConfidential()) { return $token->getUser() === $subject->getUser(); diff --git a/src/Bundle/ChillPersonBundle/config/services/controller.yaml b/src/Bundle/ChillPersonBundle/config/services/controller.yaml index 369fe63bb..fb31e8ee9 100644 --- a/src/Bundle/ChillPersonBundle/config/services/controller.yaml +++ b/src/Bundle/ChillPersonBundle/config/services/controller.yaml @@ -32,11 +32,8 @@ services: tags: ['controller.service_arguments'] Chill\PersonBundle\Controller\AccompanyingCourseController: - arguments: - $serializer: '@Symfony\Component\Serializer\SerializerInterface' - $dispatcher: '@Symfony\Contracts\EventDispatcher\EventDispatcherInterface' - $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface' - $workRepository: '@Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepository' + autoconfigure: true + autowire: true tags: ['controller.service_arguments'] Chill\PersonBundle\Controller\AccompanyingCourseApiController: From f2bf88ec908008ad0374a4c14bf9afd42211321c Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Nov 2021 08:45:28 +0100 Subject: [PATCH 5/8] adjustment to apply validation --- .../Controller/AccompanyingCourseController.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index c9b9cee35..43c516ca9 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -183,6 +183,11 @@ class AccompanyingCourseController extends Controller $workflow = $this->registry->get($accompanyingCourse); if ($workflow->can($accompanyingCourse, 'close')) { + $errors = $this->validator->validate($accompanyingCourse, null, [$accompanyingCourse::STEP_CLOSED]); + if( count($errors) > 0 ){ + return $this->json($errors, 422); + } + $workflow->apply($accompanyingCourse, 'close'); } From 26a13ae6dfa0ca7768736f969757e202262d6ad8 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Nov 2021 09:46:24 +0100 Subject: [PATCH 6/8] badge adapted+ menu entry + persistance of object fixed --- .../Controller/AccompanyingCourseController.php | 14 +++++++++++--- .../Menu/AccompanyingCourseMenuBuilder.php | 8 ++++++++ .../vuejs/AccompanyingCourse/components/Banner.vue | 7 ++++++- .../public/vuejs/AccompanyingCourse/js/i18n.js | 3 ++- .../views/AccompanyingPeriod/_list.html.twig | 4 +++- .../Authorization/AccompanyingPeriodVoter.php | 10 +++++----- .../ChillPersonBundle/translations/messages.fr.yml | 2 ++ 7 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php index 43c516ca9..8eab36d03 100644 --- a/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php +++ b/src/Bundle/ChillPersonBundle/Controller/AccompanyingCourseController.php @@ -99,7 +99,7 @@ class AccompanyingCourseController extends Controller public function indexAction(AccompanyingPeriod $accompanyingCourse): Response { $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $accompanyingCourse); - + // compute some warnings // get persons without household $withoutHousehold = []; @@ -179,7 +179,9 @@ class AccompanyingCourseController extends Controller if ($form->isSubmitted() && $form->isValid()) { - $this->getDoctrine()->getManager()->flush(); + $em = $this->getDoctrine()->getManager(); + $em->persist($accompanyingCourse); + $workflow = $this->registry->get($accompanyingCourse); if ($workflow->can($accompanyingCourse, 'close')) { @@ -187,10 +189,16 @@ class AccompanyingCourseController extends Controller if( count($errors) > 0 ){ return $this->json($errors, 422); } - $workflow->apply($accompanyingCourse, 'close'); + $em->persist($accompanyingCourse); } + $em->flush(); + + return $this->redirectToRoute('chill_person_accompanying_course_index', [ + 'accompanying_period_id' => $accompanyingCourse->getId() + ]); + } return $this->render('@ChillPerson/AccompanyingCourse/close.html.twig', [ diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index df70b9e64..599bfb309 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -67,6 +67,14 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'id' => $period->getId() ]]) ->setExtras(['order' => 40]); + + $menu->addChild($this->translator->trans('Close Accompanying Course'), [ + 'route' => 'chill_person_accompanying_course_close', + 'routeParameters' => [ + 'accompanying_period_id' => $period->getId() + ]]) + ->setExtras(['order' => 50]); + } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue index 84e7fb2c6..d83196286 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Banner.vue @@ -11,7 +11,7 @@ {{ $t('course.step.draft') }} - + {{ $t('course.step.active') }} @@ -26,6 +26,11 @@ + + + {{ $t('course.step.closed') }} + + diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js index 10b656e4a..6cd255f8d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -20,7 +20,8 @@ const appMessages = { status: "État", step: { draft: "Brouillon", - active: "En file active" + active: "En file active", + closed: "Cloturé" }, open_at: "ouvert le ", by: "par ", diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig index c5797a4b2..af8657e28 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingPeriod/_list.html.twig @@ -21,8 +21,10 @@
{% if accompanying_period.step == 'DRAFT' %} {{- 'Draft'|trans|upper -}} - {% else %} + {% elseif accompanying_period.step == 'CONFIRMED' %} {{- 'Confirmed'|trans|upper -}} + {% else %} + {{- 'Closed'|trans|upper -}} {% endif %}
diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 49847d114..9daa9ad2e 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -78,11 +78,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole return false; } - if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { - if($this->security->isGranted(self::EDIT, $subject)) { - return false; - } - } + // if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { + // if($this->security->isGranted(self::EDIT, $subject)) { + // return false; + // } + // } // if confidential, only the referent can see it if ($subject->isConfidential()) { diff --git a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml index 7f9527b91..77f988fa1 100644 --- a/src/Bundle/ChillPersonBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillPersonBundle/translations/messages.fr.yml @@ -374,6 +374,7 @@ regular: régulier Confidential: confidentiel Draft: brouillon Confirmed: en file active +Closed: Cloturé # Accompanying Course Accompanying Course: Parcours d'accompagnement @@ -381,6 +382,7 @@ Accompanying Course History: Historique du parcours Resume Accompanying Course: Résumé du parcours Show Accompanying Course: Voir le parcours Edit Accompanying Course: Modifier le parcours +Close Accompanying Course: Clôturer le parcours Create Accompanying Course: Créer un nouveau parcours Drop Accompanying Course: Supprimer le parcours This course is located at a temporarily address. You should locate this course to an user: Le parcours est localisé à une adresse temporaire. Il devrait être localisé auprès d'une personne concernée. From 210c8b8b971bc53ae649f167af69059e5093f849 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Nov 2021 11:29:29 +0100 Subject: [PATCH 7/8] voters adjusted --- .../Security/Authorization/ActivityVoter.php | 5 +++++ .../AccompanyingCourseDocumentVoter.php | 8 ++++++++ .../Authorization/AccompanyingPeriodVoter.php | 15 ++++++++------- .../Security/Authorization/TaskVoter.php | 6 ++++++ 4 files changed, 27 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php index cc9cecf52..2e6f01c6e 100644 --- a/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php +++ b/src/Bundle/ChillActivityBundle/Security/Authorization/ActivityVoter.php @@ -91,6 +91,11 @@ class ActivityVoter extends AbstractChillVoter implements ProvideRoleHierarchyIn return false; } } elseif ($subject->getAccompanyingPeriod() instanceof AccompanyingPeriod) { + if (AccompanyingPeriod::STEP_CLOSED === $subject->getAccompanyingPeriod->getStep()) { + if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE])) { + return false; + } + } if (!$this->security->isGranted(AccompanyingPeriodVoter::SEE, $subject->getAccompanyingPeriod())) { return false; } diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php index 53507d573..d93b786e2 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php @@ -76,6 +76,14 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov return false; } + if ($subject instanceof AccompanyingCourseDocument) { + if (AccompanyingPeriod::STEP_CLOSED === $subject->getCourse()->getStep()) { + if (\in_array($attribute, [self::UPDATE, self::CREATE, self::DELETE])) { + return false; + } + } + } + return $this->voterHelper->voteOnAttribute($attribute, $subject, $token); } diff --git a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php index 9daa9ad2e..4f170b2b0 100644 --- a/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php +++ b/src/Bundle/ChillPersonBundle/Security/Authorization/AccompanyingPeriodVoter.php @@ -68,6 +68,13 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole } if ($subject instanceof AccompanyingPeriod) { + + if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { + if (\in_array($attribute, [self::EDIT, self::DELETE])) { + return false; + } + } + if (AccompanyingPeriod::STEP_DRAFT === $subject->getStep()) { // only creator can see, edit, delete, etc. if ($subject->getCreatedBy() === $token->getUser() @@ -77,13 +84,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRole return false; } - - // if (AccompanyingPeriod::STEP_CLOSED === $subject->getStep()) { - // if($this->security->isGranted(self::EDIT, $subject)) { - // return false; - // } - // } - + // if confidential, only the referent can see it if ($subject->isConfidential()) { return $token->getUser() === $subject->getUser(); diff --git a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php index a3f1fff92..9e5a59c01 100644 --- a/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php +++ b/src/Bundle/ChillTaskBundle/Security/Authorization/TaskVoter.php @@ -112,6 +112,12 @@ final class TaskVoter extends AbstractChillVoter implements ProvideRoleHierarchy if (!$this->accessDecisionManager->decide($token, [AccompanyingPeriodVoter::SEE], $period)) { return false; } + + if (AccompanyingPeriod::STEP_CLOSED === $subject->getCourse()->getStep()) { + if (\in_array($attribute, [self::UPDATE, self::CREATE_COURSE, self::DELETE])) { + return false; + } + } } } From 7fe316b49aef7533ffe6c00843af02b74f4f169b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 19 Nov 2021 11:35:31 +0100 Subject: [PATCH 8/8] change menu entry order --- .../ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 599bfb309..2c978e212 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -73,7 +73,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface 'routeParameters' => [ 'accompanying_period_id' => $period->getId() ]]) - ->setExtras(['order' => 50]); + ->setExtras(['order' => 500]); }