mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-26 17:43:54 +00:00
Documents can be added/viewed/edited for an accompanyingCourse + menu entry added
This commit is contained in:
@@ -72,26 +72,12 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $course);
|
||||
|
||||
// $reachableScopes = $this->authorizationHelper
|
||||
// ->getReachableScopes(
|
||||
// $this->getUser(), new Role(PersonDocumentVoter::SEE),
|
||||
// $person->getCenter());
|
||||
|
||||
$documents = $em
|
||||
->getRepository("ChillDocStoreBundle:AccompanyingCourseDocument")
|
||||
->findBy(
|
||||
['course' => $course],
|
||||
['date' => 'DESC']
|
||||
);
|
||||
|
||||
// dump($course);
|
||||
// dump($documents);
|
||||
|
||||
// $event = new PrivacyEvent($course, [
|
||||
// 'element_class' => AccompanyingCourseDocument::class,
|
||||
// 'action' => 'index'
|
||||
// ]);
|
||||
// $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->render(
|
||||
'ChillDocStoreBundle:AccompanyingCourseDocument:index.html.twig',
|
||||
@@ -121,9 +107,9 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
$form->handleRequest($request);
|
||||
|
||||
if ($form->isSubmitted() && $form->isValid()) {
|
||||
// $this->denyAccessUnlessGranted(
|
||||
// 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', $document,
|
||||
// 'creation of this activity not allowed');
|
||||
$this->denyAccessUnlessGranted(
|
||||
'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', $document,
|
||||
'creation of this activity not allowed');
|
||||
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
$em->persist($document);
|
||||
@@ -150,13 +136,6 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
{
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', $course);
|
||||
$this->denyAccessUnlessGranted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE', $document);
|
||||
|
||||
// $event = new PrivacyEvent($person, array(
|
||||
// 'element_class' => PersonDocument::class,
|
||||
// 'element_id' => $document->getId(),
|
||||
// 'action' => 'show'
|
||||
// ));
|
||||
// $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->render(
|
||||
'ChillDocStoreBundle:AccompanyingCourseDocument:show.html.twig',
|
||||
@@ -169,7 +148,7 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
public function edit(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', $course);
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_UPDATE', $document);
|
||||
$this->denyAccessUnlessGranted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', $document);
|
||||
|
||||
$document->setUser($this->getUser());
|
||||
$document->setDate(new \DateTime('Now'));
|
||||
@@ -182,28 +161,14 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans("The document is successfully updated"));
|
||||
|
||||
// $event = new PrivacyEvent($person, array(
|
||||
// 'element_class' => PersonDocument::class,
|
||||
// 'element_id' => $document->getId(),
|
||||
// 'action' => 'update'
|
||||
// ));
|
||||
// $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->redirectToRoute(
|
||||
'accompanying_course_document_edit',
|
||||
['id' => $document->getId(), 'accompanyingCourse' => $course->getId()]);
|
||||
['id' => $document->getId(), 'course' => $course->getId()]);
|
||||
|
||||
} elseif ($form->isSubmitted() and !$form->isValid()) {
|
||||
$this->addFlash('error', $this->translator->trans("This form contains errors"));
|
||||
}
|
||||
|
||||
// $event = new PrivacyEvent($person, array(
|
||||
// 'element_class' => PersonDocument::class,
|
||||
// 'element_id' => $document->getId(),
|
||||
// 'action' => 'edit'
|
||||
// ));
|
||||
// $this->eventDispatcher->dispatch(PrivacyEvent::PERSON_PRIVACY_EVENT, $event);
|
||||
|
||||
return $this->render(
|
||||
'ChillDocStoreBundle:AccompanyingCourseDocument:edit.html.twig',
|
||||
@@ -220,7 +185,7 @@ class DocumentAccompanyingCourseController extends AbstractController
|
||||
public function delete(Request $request, AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_ACCOMPANYING_PERIOD_SEE', $course);
|
||||
$this->denyAccessUnlessGranted('CHILL_PERSON_DOCUMENT_DELETE', $document);
|
||||
$this->denyAccessUnlessGranted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_DELETE', $document);
|
||||
|
||||
if ($this->isCsrfTokenValid('delete'.$document->getId(), $request->request->get('_token'))) {
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
|
Reference in New Issue
Block a user