From c51b129a5e1f5dacb83f84a7a0da00ab792565cc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 11:02:56 +0200 Subject: [PATCH 001/121] AccompanyingCourseDocument created --- .../Entity/AccompanyingCourseDocument.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php new file mode 100644 index 000000000..9626a657d --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php @@ -0,0 +1,36 @@ +course; + } + + public function setCourse($course): self + { + $this->course = $course; + + return $this; + } +} \ No newline at end of file From 7c37a5f5832f2190dd8d527b755b6f41c5e62211 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 11:04:34 +0200 Subject: [PATCH 002/121] a bunch of files that were deleted after doing composer.phar update --- src/Bundle/ChillActivityBundle/Resources/doc/index.rst | 0 .../test/Fixtures/App/app/DoctrineMigrations/.gitignore | 2 -- src/Bundle/ChillAsideActivityBundle/CHANGELOG.md | 0 .../test/Fixtures/App/app/DoctrineMigrations/.gitignore | 2 -- .../Resources/test/Fixtures/App/logs/empty | 0 src/Bundle/ChillDocStoreBundle/.gitignore | 1 - src/Bundle/ChillEventBundle/Resources/public/chill/index.js | 1 - src/Bundle/ChillEventBundle/config/services.yaml | 2 -- src/Bundle/ChillMainBundle/Resources/doc/index.rst | 0 .../ChillMainBundle/Resources/public/lib/breadcrumb/index.js | 3 --- .../ChillMainBundle/Resources/public/lib/export-list/index.js | 1 - .../ChillMainBundle/Resources/public/lib/show_hide/index.js | 1 - .../module/scratch/contrib/bourbon/settings/_px-to-em.scss | 1 - .../ChillMainBundle/Resources/public/module/scratch/index.js | 1 - .../ChillMainBundle/Resources/public/page/login/index.js | 3 --- .../test/Fixtures/App/app/DoctrineMigrations/.gitignore | 2 -- .../Resources/test/views/menus/fakeTemplate.html.twig | 1 - .../Resources/views/CRUD/_inc/default.html.twig | 1 - 18 files changed, 22 deletions(-) delete mode 100644 src/Bundle/ChillActivityBundle/Resources/doc/index.rst delete mode 100644 src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore delete mode 100644 src/Bundle/ChillAsideActivityBundle/CHANGELOG.md delete mode 100644 src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore delete mode 100644 src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/logs/empty delete mode 100644 src/Bundle/ChillDocStoreBundle/.gitignore delete mode 100644 src/Bundle/ChillEventBundle/Resources/public/chill/index.js delete mode 100644 src/Bundle/ChillEventBundle/config/services.yaml delete mode 100644 src/Bundle/ChillMainBundle/Resources/doc/index.rst delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js delete mode 100644 src/Bundle/ChillMainBundle/Resources/public/page/login/index.js delete mode 100644 src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore delete mode 100644 src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig delete mode 100644 src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig diff --git a/src/Bundle/ChillActivityBundle/Resources/doc/index.rst b/src/Bundle/ChillActivityBundle/Resources/doc/index.rst deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/src/Bundle/ChillAsideActivityBundle/CHANGELOG.md b/src/Bundle/ChillAsideActivityBundle/CHANGELOG.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore deleted file mode 100644 index d6b7ef32c..000000000 --- a/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/logs/empty b/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/logs/empty deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Bundle/ChillDocStoreBundle/.gitignore b/src/Bundle/ChillDocStoreBundle/.gitignore deleted file mode 100644 index 57872d0f1..000000000 --- a/src/Bundle/ChillDocStoreBundle/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/vendor/ diff --git a/src/Bundle/ChillEventBundle/Resources/public/chill/index.js b/src/Bundle/ChillEventBundle/Resources/public/chill/index.js deleted file mode 100644 index adb0dd85e..000000000 --- a/src/Bundle/ChillEventBundle/Resources/public/chill/index.js +++ /dev/null @@ -1 +0,0 @@ -require('./chillevent.scss'); diff --git a/src/Bundle/ChillEventBundle/config/services.yaml b/src/Bundle/ChillEventBundle/config/services.yaml deleted file mode 100644 index 8287f32b5..000000000 --- a/src/Bundle/ChillEventBundle/config/services.yaml +++ /dev/null @@ -1,2 +0,0 @@ -services: - diff --git a/src/Bundle/ChillMainBundle/Resources/doc/index.rst b/src/Bundle/ChillMainBundle/Resources/doc/index.rst deleted file mode 100644 index e69de29bb..000000000 diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js deleted file mode 100644 index 40173696d..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require("./layout.scss"); - - diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js deleted file mode 100644 index 49e1a5b20..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js +++ /dev/null @@ -1 +0,0 @@ -require('./export-list.scss'); diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js deleted file mode 100644 index 34f3b80b5..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js +++ /dev/null @@ -1 +0,0 @@ -require("./show_hide.js"); \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss b/src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss deleted file mode 100644 index f2f9a3e8d..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss +++ /dev/null @@ -1 +0,0 @@ -$em-base: 16px !default; diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js deleted file mode 100644 index 6396103fc..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js +++ /dev/null @@ -1 +0,0 @@ -require('./scratch.scss'); diff --git a/src/Bundle/ChillMainBundle/Resources/public/page/login/index.js b/src/Bundle/ChillMainBundle/Resources/public/page/login/index.js deleted file mode 100644 index 1e6676d8f..000000000 --- a/src/Bundle/ChillMainBundle/Resources/public/page/login/index.js +++ /dev/null @@ -1,3 +0,0 @@ -require('./login.scss'); - - diff --git a/src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore deleted file mode 100644 index c96a04f00..000000000 --- a/src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig b/src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig deleted file mode 100644 index 3b1236389..000000000 --- a/src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig +++ /dev/null @@ -1 +0,0 @@ -fake template \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig deleted file mode 100644 index 0e9d6dd4c..000000000 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig +++ /dev/null @@ -1 +0,0 @@ -{{ data }} \ No newline at end of file From 3bb0e470bc9131836e91d7efd6d76cb408708820 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 11:26:04 +0200 Subject: [PATCH 003/121] entity recreated + repository + migration done --- .../Entity/AccompanyingCourseDocument.php | 38 ++++++++------ .../AccompanyingCourseDocumentRepository.php | 50 +++++++++++++++++++ .../migrations/Version20210903091534.php | 33 ++++++++++++ 3 files changed, 106 insertions(+), 15 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php create mode 100644 src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php index 9626a657d..d83b3e8e0 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php @@ -1,36 +1,44 @@ id; + } + + public function getCourse(): ?AccompanyingPeriod { return $this->course; } - public function setCourse($course): self + public function setCourse(?AccompanyingPeriod $course): self { $this->course = $course; return $this; } -} \ No newline at end of file +} diff --git a/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php b/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php new file mode 100644 index 000000000..4d6f25614 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/EntityRepository/AccompanyingCourseDocumentRepository.php @@ -0,0 +1,50 @@ +createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->orderBy('a.id', 'ASC') + ->setMaxResults(10) + ->getQuery() + ->getResult() + ; + } + */ + + /* + public function findOneBySomeField($value): ?AccompanyingCourseDocument + { + return $this->createQueryBuilder('a') + ->andWhere('a.exampleField = :val') + ->setParameter('val', $value) + ->getQuery() + ->getOneOrNullResult() + ; + } + */ +} diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php new file mode 100644 index 000000000..b19c07f09 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php @@ -0,0 +1,33 @@ +addSql('CREATE SEQUENCE chill_doc.accompanyingcourse_document_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_doc.accompanyingcourse_document (id INT NOT NULL, course_id INT NOT NULL, PRIMARY KEY(id))'); + $this->addSql('CREATE INDEX IDX_A45098F6591CC992 ON chill_doc.accompanyingcourse_document (course_id)'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP SEQUENCE chill_doc.accompanyingcourse_document_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_doc.accompanyingcourse_document'); + } +} From 46560da67d45e0bf0fed7bd714e86503fac4ca3f Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 12:20:34 +0200 Subject: [PATCH 004/121] start of controller and formtype: adaptation from DocumentPersonController --- .../DocumentAccompanyingCourseController.php | 229 ++++++++++++++++++ .../Entity/AccompanyingCourseDocument.php | 4 +- .../Form/AccompanyingCourseDocumentType.php | 96 ++++++++ 3 files changed, 327 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php create mode 100644 src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php new file mode 100644 index 000000000..9905c363e --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -0,0 +1,229 @@ +translator = $translator; + $this->eventDispatcher = $eventDispatcher; + $this->authorizationHelper = $authorizationHelper; + } + + /** + * @Route("/", name="accompanying_course_document_index", methods="GET") + */ + public function index(AccompanyingPeriod $course): Response + { + $em = $this->getDoctrine()->getManager(); + + if ($course === NULL) { + throw $this->createNotFoundException('Accompanying period not found'); + } + + $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'] + ); + + // $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', + [ + 'documents' => $documents, + 'course' => $course + ]); + } + + /** + * @Route("/new", name="accompanying_course_document_new", methods="GET|POST") + */ + public function new(Request $request, AccompanyingPeriod $course): Response + { + if ($course === NULL) { + throw $this->createNotFoundException('Accompanying period not found'); + } + + $this->denyAccessUnlessGranted(AccompanyingPeriodVoter::SEE, $course); + + $document = new AccompanyingCourseDocument(); + $document->setUser($this->getUser()); + $document->setCourse($course); + $document->setDate(new \DateTime('Now')); + + $form = $this->createForm(AccompanyingCourseDocumentType::class, $document); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $this->denyAccessUnlessGranted( + 'CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', $document, + 'creation of this activity not allowed'); + + $em = $this->getDoctrine()->getManager(); + $em->persist($document); + $em->flush(); + + $this->addFlash('success', $this->translator->trans("The document is successfully registered")); + + return $this->redirectToRoute('accompanying_course_document_index', ['course' => $course->getId()]); + } elseif ($form->isSubmitted() and !$form->isValid()) { + $this->addFlash('error', $this->translator->trans("This form contains errors")); + } + + return $this->render('ChillDocStoreBundle:AccompanyingCourseDocument:new.html.twig', [ + 'document' => $document, + 'form' => $form->createView(), + 'course' => $course, + ]); + } + + /** + * @Route("/{id}", name="accompanying_course_document_show", methods="GET") + */ + public function show(AccompanyingPeriod $course, AccompanyingCourseDocument $document): Response + { + $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', + ['document' => $document, 'course' => $course]); + } + + /** + * @Route("/{id}/edit", name="accompanying_course_document_edit", methods="GET|POST") + */ + 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); + + $document->setUser($this->getUser()); + $document->setDate(new \DateTime('Now')); + + $form = $this->createForm( + AccompanyingCourseDocumentType::class, $document); + $form->handleRequest($request); + + if ($form->isSubmitted() && $form->isValid()) { + $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(), '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', + [ + 'document' => $document, + 'form' => $form->createView(), + 'person' => $course, + ]); + } + + /** + * @Route("/{id}", name="accompanying_course_document_delete", methods="DELETE") + */ + 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); + + if ($this->isCsrfTokenValid('delete'.$document->getId(), $request->request->get('_token'))) { + $em = $this->getDoctrine()->getManager(); + $em->remove($document); + $em->flush(); + } + + return $this->redirectToRoute( + 'accompanying_course_document_index', ['course' => $course->getId()]); + } +} diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php index d83b3e8e0..beadbc27d 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php @@ -2,7 +2,7 @@ namespace App\Entity; -use App\Repository\AccompanyingCourseDocumentRepository; +use Chill\DocStoreBundle\Entity\Document; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Doctrine\ORM\Mapping as ORM; @@ -10,7 +10,7 @@ use Doctrine\ORM\Mapping as ORM; * @ORM\Entity(repositoryClass=AccompanyingCourseDocumentRepository::class) * @ORM\Table("chill_doc.accompanyingcourse_document") */ -class AccompanyingCourseDocument +class AccompanyingCourseDocument extends Document { /** * @ORM\Id diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php new file mode 100644 index 000000000..c24d7a910 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -0,0 +1,96 @@ +translatableStringHelper = $translatableStringHelper; + } + + + public function buildForm(FormBuilderInterface $builder, array $options) + { + $builder + ->add('title', TextType::class) + ->add('description', ChillTextareaType::class, [ + 'required' => false + ]) + ->add('object', StoredObjectType::class, [ + 'error_bubbling' => true + ]) + ->add('date', ChillDateType::class) + ->add('category', EntityType::class, array( + 'placeholder' => 'Choose a document category', + 'class' => 'ChillDocStoreBundle:DocumentCategory', + 'query_builder' => function (EntityRepository $er) { + return $er->createQueryBuilder('c') + ->where('c.documentClass = :docClass') + ->setParameter('docClass', AccompanyingCourseDocument::class); + }, + 'choice_label' => function ($entity = null) { + return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; + }, + )) + ; + + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => Document::class, + ]); + + // $resolver->setRequired(['role', 'center']) + // ->setAllowedTypes('role', [ \Symfony\Component\Security\Core\Role\Role::class ]) + // ->setAllowedTypes('center', [ \Chill\MainBundle\Entity\Center::class ]) + // ; + } +} From aad0d295efa05518e603eb0c99757f518b00f3ff Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 12:29:51 +0200 Subject: [PATCH 005/121] services added to config files --- .../ChillDocStoreBundle/config/services.yaml | 50 +++++++++---------- .../config/services/controller.yaml | 27 ++++++---- .../config/services/form.yaml | 17 +++++-- 3 files changed, 54 insertions(+), 40 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 812edab06..232edec3f 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -2,31 +2,31 @@ parameters: # cl_chill_person.example.class: Chill\PersonBundle\Example services: - Chill\DocStoreBundle\Repository\: - autowire: true - autoconfigure: true - resource: '../Repository/' - tags: ['doctrine.repository_service'] + Chill\DocStoreBundle\Repository\: + autowire: true + autoconfigure: true + resource: "../Repository/" + tags: ["doctrine.repository_service"] - Chill\DocStoreBundle\Form\DocumentCategoryType: - class: Chill\DocStoreBundle\Form\DocumentCategoryType - arguments: ['%kernel.bundles%'] - tags: - - { name: form.type } + Chill\DocStoreBundle\Form\DocumentCategoryType: + class: Chill\DocStoreBundle\Form\DocumentCategoryType + arguments: ["%kernel.bundles%"] + tags: + - { name: form.type } - Chill\DocStoreBundle\Form\PersonDocumentType: - class: Chill\DocStoreBundle\Form\PersonDocumentType - arguments: - - "@chill.main.helper.translatable_string" - tags: - - { name: form.type, alias: chill_docstorebundle_form_document } + Chill\DocStoreBundle\Form\PersonDocumentType: + class: Chill\DocStoreBundle\Form\PersonDocumentType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type, alias: chill_docstorebundle_form_document } - Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter: - class: Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter - arguments: - - "@security.access.decision_manager" - - "@chill.main.security.authorization.helper" - - "@logger" - tags: - - { name: security.voter } - - { name: chill.role } + Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter: + class: Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter + arguments: + - "@security.access.decision_manager" + - "@chill.main.security.authorization.helper" + - "@logger" + tags: + - { name: security.voter } + - { name: chill.role } diff --git a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml index 9899ffa2e..5a6b5a5fc 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml @@ -1,11 +1,18 @@ services: - Chill\DocStoreBundle\Controller\: - resource: '../../Controller' - tags: ['controller.service_arguments'] - - Chill\DocStoreBundle\Controller\DocumentPersonController: - arguments: - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' - tags: ['controller.service_arguments'] \ No newline at end of file + Chill\DocStoreBundle\Controller\: + resource: "../../Controller" + tags: ["controller.service_arguments"] + + Chill\DocStoreBundle\Controller\DocumentPersonController: + arguments: + $translator: '@Symfony\Component\Translation\TranslatorInterface' + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + tags: ["controller.service_arguments"] + + Chill\DocStoreBundle\Controller\DocumentAccompanyingCourseController: + arguments: + $translator: '@Symfony\Component\Translation\TranslatorInterface' + $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' + $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' + tags: ["controller.service_arguments"] diff --git a/src/Bundle/ChillDocStoreBundle/config/services/form.yaml b/src/Bundle/ChillDocStoreBundle/config/services/form.yaml index c84507e51..8d53d81f1 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services/form.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services/form.yaml @@ -1,6 +1,13 @@ services: - Chill\DocStoreBundle\Form\StoredObjectType: - arguments: - $em: '@Doctrine\ORM\EntityManagerInterface' - tags: - - { name: form.type } + Chill\DocStoreBundle\Form\StoredObjectType: + arguments: + $em: '@Doctrine\ORM\EntityManagerInterface' + tags: + - { name: form.type } + + Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType: + class: Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType + arguments: + - "@chill.main.helper.translatable_string" + tags: + - { name: form.type, alias: chill_docstorebundle_form_document } From b11592fb6d14d642dde32b2e5dc83ef520f1be4b Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 16:05:55 +0200 Subject: [PATCH 006/121] templates added and adapted, still problems with scope --- .../DocumentAccompanyingCourseController.php | 18 +- .../Entity/AccompanyingCourseDocument.php | 11 +- .../AccompanyingCourseDocumentRepository.php | 2 +- .../_delete_form.html.twig | 5 + .../AccompanyingCourseDocument/edit.html.twig | 45 ++++ .../index.html.twig | 70 ++++++ .../AccompanyingCourseDocument/new.html.twig | 45 ++++ .../AccompanyingCourseDocument/show.html.twig | 61 +++++ .../views/PersonDocument/new.html.twig | 48 ++-- .../migrations/Version20210903123835.php | 227 ++++++++++++++++++ .../views/AccompanyingCourse/banner.html.twig | 53 ++-- 11 files changed, 518 insertions(+), 67 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/_delete_form.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig create mode 100644 src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 9905c363e..3f3c62cf4 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -2,7 +2,8 @@ namespace Chill\DocStoreBundle\Controller; -use App\Entity\AccompanyingCourseDocument; +use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument; +use Chill\DocStoreBundle\Form\AccompanyingCourseDocumentType; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Privacy\PrivacyEvent; @@ -12,12 +13,13 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Contracts\Translation\TranslatorInterface; +use Symfony\Component\Routing\Annotation\Route; /** * Class DocumentAccompanyingCourseController * * @package Chill\DocStoreBundle\Controller - * @Route("/{_locale}/parcours/course/document") + * @Route("/{_locale}/parcours/{course}/document") * * TODO faire un controller abstrait ? */ @@ -92,7 +94,7 @@ class DocumentAccompanyingCourseController extends AbstractController 'ChillDocStoreBundle:AccompanyingCourseDocument:index.html.twig', [ 'documents' => $documents, - 'course' => $course + 'accompanyingCourse' => $course ]); } @@ -134,7 +136,7 @@ class DocumentAccompanyingCourseController extends AbstractController return $this->render('ChillDocStoreBundle:AccompanyingCourseDocument:new.html.twig', [ 'document' => $document, 'form' => $form->createView(), - 'course' => $course, + 'accompanyingCourse' => $course, ]); } @@ -155,7 +157,7 @@ class DocumentAccompanyingCourseController extends AbstractController return $this->render( 'ChillDocStoreBundle:AccompanyingCourseDocument:show.html.twig', - ['document' => $document, 'course' => $course]); + ['document' => $document, 'accompanyingCourse' => $course]); } /** @@ -187,7 +189,7 @@ class DocumentAccompanyingCourseController extends AbstractController return $this->redirectToRoute( 'accompanying_course_document_edit', - ['id' => $document->getId(), 'course' => $course->getId()]); + ['id' => $document->getId(), 'accompanyingCourse' => $course->getId()]); } elseif ($form->isSubmitted() and !$form->isValid()) { $this->addFlash('error', $this->translator->trans("This form contains errors")); @@ -205,7 +207,7 @@ class DocumentAccompanyingCourseController extends AbstractController [ 'document' => $document, 'form' => $form->createView(), - 'person' => $course, + 'accompanyingCourse' => $course, ]); } @@ -224,6 +226,6 @@ class DocumentAccompanyingCourseController extends AbstractController } return $this->redirectToRoute( - 'accompanying_course_document_index', ['course' => $course->getId()]); + 'accompanying_course_document_index', ['accompanyingCourse' => $course->getId()]); } } diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php index beadbc27d..3649bd51c 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php @@ -1,24 +1,17 @@ + + + + diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig new file mode 100644 index 000000000..e2b0a9559 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig @@ -0,0 +1,45 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% block title %} + {# {{ 'Editing document for %name%'|trans({ '%name%': accompanyingCourse|chill_entity_render_string } ) }} #} +{% endblock %} +{% block accompanyingCoursecontent %} + +

{{ 'Edit Document' | trans }}

+ + {{ form_errors(form) }} + + {{ form_start(form) }} + + {{ form_row(form.title) }} + {{ form_row(form.date) }} + {{ form_row(form.category) }} + {{ form_row(form.scope) }} + {{ form_row(form.description) }} + {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} + + + + {{ form_end(form) }} + + +{% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_async_upload') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_async_upload') }} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig new file mode 100644 index 000000000..3e8ed7f9c --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -0,0 +1,70 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} + +{% block title %} + {{ 'Documents' }} +{% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_async_upload') }} +{% endblock %} + +{% block content %} +

{{ 'Documents' }}

+ + + + + + + + + + + + {% for document in documents %} + + + + + + + {% else %} + + + + {% endfor %} + +
{{ 'Title' | trans }}{{ 'Category'|trans }}{{ 'Circle' | trans }}{{ 'Actions' | trans }}
{{ document.title }}{{ document.category.name|localize_translatable_string }}{{ document.scope.name|localize_translatable_string }} +
    + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %} +
  • + {{ m.download_button(document.object, document.title) }} +
  • +
  • + +
  • + {% endif %} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} +
  • + +
  • + {% endif %} +
+
+ {{ 'Any document found'|trans }} +
+ + {# {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', accompanyingCourse) %} #} + + {# {% endif %} #} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig new file mode 100644 index 000000000..b3b9950ab --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig @@ -0,0 +1,45 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% block title %} + {# {{ 'New document for %name%'|trans({ '%name%': accompanyingCourse|chill_entity_render_string } ) }} #} +{% endblock %} + + +{% block content %} + + {#

{{ 'New document for %name%'|trans({ '%name%': accompanyingCourse|chill_entity_render_string } ) }}

#} + + + {{ form_errors(form) }} + + {{ form_start(form) }} + + {{ form_row(form.title) }} + {{ form_row(form.date) }} + {{ form_row(form.category) }} + {# {{ form_row(form.scope) }} #} + {{ form_row(form.description) }} + {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} + + + {{ form_end(form) }} +{% endblock %} + +{% block js %} + {{ encore_entry_script_tags('mod_async_upload') }} +{% endblock %} + +{% block css %} + {{ encore_entry_link_tags('mod_async_upload') }} +{% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig new file mode 100644 index 000000000..901d84540 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig @@ -0,0 +1,61 @@ +{% extends "@ChillPerson/AccompanyingCourse/layout.html.twig" %} + +{% set activeRouteKey = '' %} + +{% import "@ChillDocStore/Macro/macro.html.twig" as m %} + +{% block title %} + {# {{ 'Detail of document of %name%'|trans({ '%name%': accompanyingCourse|chill_entity_render_string } ) }} #} +{% endblock %} + + +{% block js %} + {{ encore_entry_script_tags('mod_async_upload') }} +{% endblock %} + +{% block accompanyingCoursecontent %} + +

{{ 'Document %title%' | trans({ '%title%': document.title }) }}

+ +
+
{{ 'Title'|trans }}
+
{{ document.title }}
+ +
{{ 'Scope' | trans }}
+
{{ document.scope.name | localize_translatable_string }}
+ +
{{ 'Category'|trans }}
+
{{ document.category.name|localize_translatable_string }}
+ +
{{ 'Description' | trans }}
+
+ {% if document.description is empty %} + {{ 'Any description'|trans }} + {% else %} +
+ {{ document.description|chill_markdown_to_html }} +
+ {% endif %} +
+ +
+ +
    +
  • + + {{ 'Back to the list' | trans }} + +
  • + +
  • + {{ m.download_button(document.object, document.title) }} +
  • + + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} +
  • + + {{ 'Edit' | trans }} + +
  • + {% endif %} + {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig index b60ad6550..73d8cddf5 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/new.html.twig @@ -18,39 +18,41 @@ {% set activeRouteKey = '' %} -{% block title %}{{ 'New document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}{% endblock %} +{% block title %} + {{ 'New document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }} +{% endblock %} {% block personcontent %} -

    {{ 'New document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}

    +

    {{ 'New document for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}

    - {{ form_errors(form) }} + {{ form_errors(form) }} - {{ form_start(form) }} + {{ form_start(form) }} - {{ form_row(form.title) }} - {{ form_row(form.date) }} - {{ form_row(form.category) }} - {{ form_row(form.scope) }} - {{ form_row(form.description) }} - {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} + {{ form_row(form.title) }} + {{ form_row(form.date) }} + {{ form_row(form.category) }} + {{ form_row(form.scope) }} + {{ form_row(form.description) }} + {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }} - - {{ form_end(form) }} + + {{ form_end(form) }} {% endblock %} {% block js %} - {{ encore_entry_script_tags('mod_async_upload') }} + {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} {% block css %} - {{ encore_entry_link_tags('mod_async_upload') }} + {{ encore_entry_link_tags('mod_async_upload') }} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php new file mode 100644 index 000000000..bb5b9d973 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php @@ -0,0 +1,227 @@ +addSql('DROP SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq CASCADE'); + // $this->addSql('CREATE SEQUENCE chill_docgen_template_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + // $this->addSql('CREATE TABLE chill_docgen_template (id INT NOT NULL, name JSON NOT NULL, description TEXT DEFAULT NULL, entities TEXT NOT NULL, context VARCHAR(255) NOT NULL, file VARCHAR(255) NOT NULL, PRIMARY KEY(id))'); + // $this->addSql('COMMENT ON COLUMN chill_docgen_template.name IS \'(DC2Type:json_array)\''); + // $this->addSql('COMMENT ON COLUMN chill_docgen_template.entities IS \'(DC2Type:simple_array)\''); + // $this->addSql('DROP TABLE chill_main_address_legacy'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD category_bundle_id VARCHAR(255) DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD category_id_inside_bundle INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD object_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD scope_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD user_id INT DEFAULT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD title TEXT NOT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD description TEXT NOT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6369A0BE36EF62EFC FOREIGN KEY (category_bundle_id, category_id_inside_bundle) REFERENCES chill_doc.document_category (bundle_id, id_inside_bundle) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6232D562B FOREIGN KEY (object_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6682B5931 FOREIGN KEY (scope_id) REFERENCES scopes (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6A76ED395 FOREIGN KEY (user_id) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + $this->addSql('CREATE INDEX IDX_A45098F6369A0BE36EF62EFC ON chill_doc.accompanyingcourse_document (category_bundle_id, category_id_inside_bundle)'); + $this->addSql('CREATE INDEX IDX_A45098F6232D562B ON chill_doc.accompanyingcourse_document (object_id)'); + $this->addSql('CREATE INDEX IDX_A45098F6682B5931 ON chill_doc.accompanyingcourse_document (scope_id)'); + $this->addSql('CREATE INDEX IDX_A45098F6A76ED395 ON chill_doc.accompanyingcourse_document (user_id)'); + // $this->addSql('ALTER INDEX idx_55026b0ca76ed395 RENAME TO IDX_AC74095AA76ED395'); + // $this->addSql('ALTER INDEX idx_55026b0cc54c8c93 RENAME TO IDX_AC74095AC54C8C93'); + // $this->addSql('ALTER INDEX idx_55026b0c682b5931 RENAME TO IDX_AC74095A682B5931'); + // $this->addSql('ALTER INDEX idx_55026b0c217bbb47 RENAME TO IDX_AC74095A217BBB47'); + // $this->addSql('ALTER INDEX idx_ac74095a550b0c53 RENAME TO IDX_AC74095AD7FA8EF0'); + // $this->addSql('ALTER TABLE activityreason ALTER name SET NOT NULL'); + // $this->addSql('COMMENT ON COLUMN activityreason.name IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER INDEX idx_654a2fcd12469de2 RENAME TO IDX_AF82522312469DE2'); + // $this->addSql('ALTER TABLE activityreasoncategory ALTER name SET NOT NULL'); + // $this->addSql('COMMENT ON COLUMN activityreasoncategory.name IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER TABLE chill_main_address DROP customs'); + // $this->addSql('ALTER TABLE chill_main_address ALTER isnoaddress DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE geometry(POINT,4326)'); + // $this->addSql('ALTER TABLE chill_main_address ALTER point DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point TYPE geometry(POINT,4326)'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point DROP DEFAULT'); + // $this->addSql('CREATE INDEX search_name_code ON chill_main_postal_code (code, label)'); + // $this->addSql('ALTER INDEX idx_64a4a621504cb38d RENAME TO IDX_E260A868504CB38D'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive ALTER ordering DROP DEFAULT'); + // $this->addSql('ALTER INDEX idx_92351ece727aca70 RENAME TO IDX_72D110E8727ACA70'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_participation ALTER startdate DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD template_id INT DEFAULT NULL'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD storedObject_id INT DEFAULT NULL'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD CONSTRAINT FK_33EC92296C99C13A FOREIGN KEY (storedObject_id) REFERENCES chill_doc.stored_object (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ADD CONSTRAINT FK_33EC92295DA0FB8 FOREIGN KEY (template_id) REFERENCES chill_docgen_template (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('CREATE INDEX IDX_33EC92296C99C13A ON chill_person_accompanying_period_work_evaluation_document (storedObject_id)'); + // $this->addSql('CREATE INDEX IDX_33EC92295DA0FB8 ON chill_person_accompanying_period_work_evaluation_document (template_id)'); + // $this->addSql('ALTER TABLE chill_person_household DROP CONSTRAINT fk_household_comment_embeddable_user'); + // $this->addSql('DROP INDEX IDX_BE50A270116F5FA9'); + // $this->addSql('DROP INDEX household_members_not_overlaps'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startdate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startdate DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER enddate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER enddate DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.startDate IS \'(DC2Type:date_immutable)\''); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.endDate IS \'(DC2Type:date_immutable)\''); + // $this->addSql('ALTER TABLE chill_person_marital_status ALTER id TYPE VARCHAR(7)'); + // $this->addSql('COMMENT ON COLUMN chill_person_marital_status.name IS \'(DC2Type:json_array)\''); + // $this->addSql('DROP INDEX fullnamecanonical_trgm_idx'); + // $this->addSql('DROP INDEX phonenumber_trgm_idx'); + // $this->addSql('DROP INDEX mobilenumber_trgm_idx'); + // $this->addSql('ALTER TABLE chill_person_person DROP cfdata_old'); + // $this->addSql('ALTER TABLE chill_person_person ALTER maritalstatus_id TYPE VARCHAR(7)'); + // $this->addSql('ALTER TABLE chill_person_person ALTER cfdata SET NOT NULL'); + // $this->addSql('COMMENT ON COLUMN chill_person_person.cFData IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER INDEX idx_3370d4403818da5 RENAME TO IDX_BF210A143818DA5'); + // $this->addSql('ALTER INDEX idx_3370d4401c9da55 RENAME TO IDX_BF210A141C9DA55'); + // $this->addSql('ALTER INDEX idx_bf210a145521be40 RENAME TO IDX_BF210A14D7D03CE3'); + // $this->addSql('ALTER INDEX idx_person_center RENAME TO IDX_BF210A145932F377'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT FK_7201106F217BBB47'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT FK_7201106F82F1BAF4'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F217BBB47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT FK_7201106F82F1BAF4 FOREIGN KEY (language_id) REFERENCES language (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('COMMENT ON COLUMN country.name IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER TABLE custom_field_long_choice_options ALTER internal_key DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN custom_field_long_choice_options.text IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER TABLE customfield ALTER required DROP DEFAULT'); + // $this->addSql('ALTER TABLE customfield ALTER required SET NOT NULL'); + // $this->addSql('COMMENT ON COLUMN customfield.name IS \'(DC2Type:json_array)\''); + // $this->addSql('COMMENT ON COLUMN customfield.options IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER INDEX idx_40fb5d6dfec418b RENAME TO IDX_7A6FDBEFEC418B'); + // $this->addSql('ALTER INDEX idx_286dc95df53b66 RENAME TO IDX_7A48DF7F5DF53B66'); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP DEFAULT'); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options SET NOT NULL'); + // $this->addSql('COMMENT ON COLUMN customfieldsgroup.name IS \'(DC2Type:json_array)\''); + // $this->addSql('COMMENT ON COLUMN customfieldsgroup.options IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER INDEX idx_a14d8f3d447bbb3b RENAME TO IDX_A14D8F3D96DF1F10'); + // $this->addSql('COMMENT ON COLUMN language.name IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER TABLE permission_groups ALTER flags DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN scopes.name IS \'(DC2Type:json_array)\''); + // $this->addSql('ALTER TABLE chill_3party.third_party ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + // $this->addSql('ALTER TABLE chill_3party.third_party ALTER created_at DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_3party.third_party.created_at IS \'(DC2Type:datetime_immutable)\''); + // $this->addSql('ALTER TABLE users ALTER usernamecanonical SET NOT NULL'); + // $this->addSql('DROP INDEX uniq_93f763ae217bbb47'); + // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage ADD CONSTRAINT FK_4D319FFEF57537C3 FOREIGN KEY (vendeeperson_id) REFERENCES chill_vendee.vendee_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER INDEX chill_vendee.idx_1a4b602deef79338 RENAME TO IDX_DD0A4C00EEF79338'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + // $this->addSql('CREATE SCHEMA public'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP CONSTRAINT FK_33EC92295DA0FB8'); + // $this->addSql('DROP SEQUENCE chill_docgen_template_id_seq CASCADE'); + // $this->addSql('CREATE SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + // $this->addSql('CREATE TABLE chill_main_address_legacy (id INT DEFAULT NULL, postcode_id INT DEFAULT NULL, street VARCHAR(255) DEFAULT NULL, streetnumber VARCHAR(255) DEFAULT NULL, validfrom DATE DEFAULT NULL, isnoaddress BOOLEAN DEFAULT NULL, customs JSONB DEFAULT NULL, floor VARCHAR(16) DEFAULT NULL, corridor VARCHAR(16) DEFAULT NULL, steps VARCHAR(16) DEFAULT NULL, buildingname VARCHAR(255) DEFAULT NULL, flat VARCHAR(16) DEFAULT NULL, distribution VARCHAR(255) DEFAULT NULL, extra VARCHAR(255) DEFAULT NULL, validto DATE DEFAULT NULL, point VARCHAR(255) DEFAULT NULL, linkedtothirdparty_id INT DEFAULT NULL)'); + // $this->addSql('DROP TABLE chill_docgen_template'); + // $this->addSql('ALTER TABLE chill_3party.third_party ALTER created_at TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + // $this->addSql('ALTER TABLE chill_3party.third_party ALTER created_at SET DEFAULT \'2015-01-01 00:00:00\''); + // $this->addSql('COMMENT ON COLUMN chill_3party.third_party.created_at IS NULL'); + // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage DROP CONSTRAINT FK_4D319FFEF57537C3'); + // $this->addSql('ALTER TABLE activityreason ALTER name DROP NOT NULL'); + // $this->addSql('COMMENT ON COLUMN activityreason.name IS NULL'); + // $this->addSql('ALTER INDEX idx_af82522312469de2 RENAME TO idx_654a2fcd12469de2'); + // $this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL'); + // $this->addSql('COMMENT ON COLUMN activityreasoncategory.name IS NULL'); + // $this->addSql('ALTER INDEX chill_vendee.idx_dd0a4c00eef79338 RENAME TO idx_1a4b602deef79338'); + // $this->addSql('CREATE UNIQUE INDEX uniq_93f763ae217bbb47 ON chill_vendee.vendee_person (person_id)'); + // $this->addSql('ALTER INDEX idx_ac74095aa76ed395 RENAME TO idx_55026b0ca76ed395'); + // $this->addSql('ALTER INDEX idx_ac74095a682b5931 RENAME TO idx_55026b0c682b5931'); + // $this->addSql('ALTER INDEX idx_ac74095ac54c8c93 RENAME TO idx_55026b0cc54c8c93'); + // $this->addSql('ALTER INDEX idx_ac74095a217bbb47 RENAME TO idx_55026b0c217bbb47'); + // $this->addSql('ALTER INDEX idx_ac74095ad7fa8ef0 RENAME TO IDX_AC74095A550B0C53'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point TYPE VARCHAR(255)'); + // $this->addSql('ALTER TABLE chill_main_address_reference ALTER point DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_participation ALTER startDate SET DEFAULT \'1970-01-01\''); + // $this->addSql('ALTER INDEX idx_e260a868504cb38d RENAME TO idx_64a4a621504cb38d'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP CONSTRAINT FK_33EC92296C99C13A'); + // $this->addSql('DROP INDEX IDX_33EC92296C99C13A'); + // $this->addSql('DROP INDEX IDX_33EC92295DA0FB8'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP template_id'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document DROP storedObject_id'); + // $this->addSql('ALTER TABLE chill_person_accompanying_period_closingmotive ALTER ordering SET DEFAULT \'0\''); + // $this->addSql('ALTER INDEX idx_72d110e8727aca70 RENAME TO idx_92351ece727aca70'); + // $this->addSql('ALTER TABLE chill_person_person ADD cfdata_old TEXT DEFAULT NULL'); + // $this->addSql('ALTER TABLE chill_person_person ALTER cFData DROP NOT NULL'); + // $this->addSql('ALTER TABLE chill_person_person ALTER maritalStatus_id TYPE VARCHAR(10)'); + // $this->addSql('COMMENT ON COLUMN chill_person_person.cfdata_old IS \'(DC2Type:array)\''); + // $this->addSql('COMMENT ON COLUMN chill_person_person.cfdata IS NULL'); + // $this->addSql('CREATE INDEX fullnamecanonical_trgm_idx ON chill_person_person (fullnamecanonical)'); + // $this->addSql('CREATE INDEX phonenumber_trgm_idx ON chill_person_person (phonenumber)'); + // $this->addSql('CREATE INDEX mobilenumber_trgm_idx ON chill_person_person (mobilenumber)'); + // $this->addSql('ALTER INDEX idx_bf210a143818da5 RENAME TO idx_3370d4403818da5'); + // $this->addSql('ALTER INDEX idx_bf210a141c9da55 RENAME TO idx_3370d4401c9da55'); + // $this->addSql('ALTER INDEX idx_bf210a145932f377 RENAME TO idx_person_center'); + // $this->addSql('ALTER INDEX idx_bf210a14d7d03ce3 RENAME TO IDX_BF210A145521BE40'); + // $this->addSql('ALTER TABLE chill_person_marital_status ALTER id TYPE VARCHAR(10)'); + // $this->addSql('COMMENT ON COLUMN chill_person_marital_status.name IS NULL'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startDate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER startDate DROP DEFAULT'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER endDate TYPE DATE'); + // $this->addSql('ALTER TABLE chill_person_household_members ALTER endDate DROP DEFAULT'); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.startdate IS NULL'); + // $this->addSql('COMMENT ON COLUMN chill_person_household_members.enddate IS NULL'); + // $this->addSql('CREATE INDEX household_members_not_overlaps ON chill_person_household_members (person_id) WHERE (sharedhousehold IS TRUE)'); + // $this->addSql('ALTER TABLE chill_person_household ADD CONSTRAINT fk_household_comment_embeddable_user FOREIGN KEY (comment_members_userid) REFERENCES users (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('CREATE INDEX IDX_BE50A270116F5FA9 ON chill_person_household (comment_members_userid)'); + // $this->addSql('ALTER TABLE customfield ALTER required SET DEFAULT \'false\''); + // $this->addSql('ALTER TABLE customfield ALTER required DROP NOT NULL'); + // $this->addSql('COMMENT ON COLUMN customfield.options IS NULL'); + // $this->addSql('COMMENT ON COLUMN customfield.name IS NULL'); + // $this->addSql('ALTER INDEX idx_7a6fdbefec418b RENAME TO idx_40fb5d6dfec418b'); + // $this->addSql('ALTER INDEX idx_a14d8f3d96df1f10 RENAME TO idx_a14d8f3d447bbb3b'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT fk_7201106f217bbb47'); + // $this->addSql('ALTER TABLE persons_spoken_languages DROP CONSTRAINT fk_7201106f82f1baf4'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT fk_7201106f217bbb47 FOREIGN KEY (person_id) REFERENCES chill_person_person (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE persons_spoken_languages ADD CONSTRAINT fk_7201106f82f1baf4 FOREIGN KEY (language_id) REFERENCES language (id) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('COMMENT ON COLUMN country.name IS NULL'); + // $this->addSql('ALTER TABLE permission_groups ALTER flags SET DEFAULT \'[]\''); + // $this->addSql('ALTER TABLE custom_field_long_choice_options ALTER internal_key SET DEFAULT \'\''); + // $this->addSql('COMMENT ON COLUMN custom_field_long_choice_options.text IS NULL'); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options SET DEFAULT \'{}\''); + // $this->addSql('ALTER TABLE customfieldsgroup ALTER options DROP NOT NULL'); + // $this->addSql('COMMENT ON COLUMN customfieldsgroup.name IS NULL'); + // $this->addSql('COMMENT ON COLUMN customfieldsgroup.options IS NULL'); + // $this->addSql('COMMENT ON COLUMN language.name IS NULL'); + // $this->addSql('COMMENT ON COLUMN scopes.name IS NULL'); + // $this->addSql('ALTER TABLE users ALTER usernameCanonical DROP NOT NULL'); + // $this->addSql('ALTER TABLE chill_main_address ADD customs JSONB DEFAULT \'[]\''); + // $this->addSql('ALTER TABLE chill_main_address ALTER isNoAddress SET DEFAULT \'false\''); + // $this->addSql('ALTER TABLE chill_main_address ALTER point TYPE VARCHAR(255)'); + // $this->addSql('ALTER TABLE chill_main_address ALTER point DROP DEFAULT'); + // $this->addSql('DROP INDEX search_name_code'); + // $this->addSql('ALTER INDEX idx_7a48df7f5df53b66 RENAME TO idx_286dc95df53b66'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F6369A0BE36EF62EFC'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F6232D562B'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F6682B5931'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP CONSTRAINT FK_A45098F6A76ED395'); + $this->addSql('DROP INDEX IDX_A45098F6369A0BE36EF62EFC'); + $this->addSql('DROP INDEX IDX_A45098F6232D562B'); + $this->addSql('DROP INDEX IDX_A45098F6682B5931'); + $this->addSql('DROP INDEX IDX_A45098F6A76ED395'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP category_bundle_id'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP category_id_inside_bundle'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP object_id'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP scope_id'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP user_id'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP title'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP description'); + $this->addSql('ALTER TABLE chill_doc.accompanyingcourse_document DROP date'); + } +} diff --git a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig index b405f9bae..e55b39f64 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/banner.html.twig @@ -1,35 +1,36 @@ From 5211fb2fe959eb8b22b4bc2b2c04acf11e27651d Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 9 Sep 2021 16:42:53 +0200 Subject: [PATCH 007/121] Documents added to accompanying course menu --- .../test/Fixtures/App/app/Resources/.DS_Store | Bin 6148 -> 0 bytes .../DocumentAccompanyingCourseController.php | 9 ++++++--- .../Form/AccompanyingCourseDocumentType.php | 2 +- .../AccompanyingCourseDocument/index.html.twig | 6 +++--- .../Menu/AccompanyingCourseMenuBuilder.php | 9 ++++++++- .../Resources/test/Fixtures/.DS_Store | Bin 6148 -> 0 bytes 6 files changed, 18 insertions(+), 8 deletions(-) delete mode 100644 src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/Resources/.DS_Store delete mode 100644 src/Bundle/ChillReportBundle/Resources/test/Fixtures/.DS_Store diff --git a/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/Resources/.DS_Store b/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/Resources/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 'DESC'] ); + // dump($course); + // dump($documents); + // $event = new PrivacyEvent($course, [ // 'element_class' => AccompanyingCourseDocument::class, // 'action' => 'index' @@ -118,9 +121,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); diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index c24d7a910..bdaea7ee0 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -72,7 +72,7 @@ class AccompanyingCourseDocumentType extends AbstractType 'query_builder' => function (EntityRepository $er) { return $er->createQueryBuilder('c') ->where('c.documentClass = :docClass') - ->setParameter('docClass', AccompanyingCourseDocument::class); + ->setParameter('docClass', PersonDocument::class); }, 'choice_label' => function ($entity = null) { return $entity ? $this->translatableStringHelper->localize($entity->getName()) : ''; diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig index 3e8ed7f9c..114dbb342 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -29,7 +29,7 @@ {{ document.title }} {{ document.category.name|localize_translatable_string }} - {{ document.scope.name|localize_translatable_string }} + {# {{ document.scope.name|localize_translatable_string }} #}
      {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %} @@ -37,12 +37,12 @@ {{ m.download_button(document.object, document.title) }}
    • - +
    • {% endif %} {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
    • - +
    • {% endif %}
    diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 744e5dbbe..41de5718d 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -61,12 +61,19 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface ]]) ->setExtras(['order' => 30]); + $menu->addChild($this->translator->trans('Documents'), [ + 'route' => 'accompanying_course_document_index', + 'routeParameters' => [ + 'course' => $period->getId() + ]]) + ->setExtras(['order' => 40]); + $menu->addChild($this->translator->trans('Accompanying Course Action'), [ 'route' => 'chill_person_accompanying_period_work_list', 'routeParameters' => [ 'id' => $period->getId() ]]) - ->setExtras(['order' => 40]); + ->setExtras(['order' => 50]); } diff --git a/src/Bundle/ChillReportBundle/Resources/test/Fixtures/.DS_Store b/src/Bundle/ChillReportBundle/Resources/test/Fixtures/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Thu, 9 Sep 2021 16:46:26 +0200 Subject: [PATCH 008/121] track all files added in other bundles --- src/Bundle/ChillActivityBundle/Resources/doc/index.rst | 0 .../test/Fixtures/App/app/DoctrineMigrations/.gitignore | 2 ++ src/Bundle/ChillAsideActivityBundle/CHANGELOG.md | 0 .../test/Fixtures/App/app/DoctrineMigrations/.gitignore | 2 ++ .../Resources/test/Fixtures/App/logs/empty | 0 src/Bundle/ChillDocStoreBundle/.gitignore | 1 + src/Bundle/ChillEventBundle/Resources/public/chill/index.js | 1 + src/Bundle/ChillEventBundle/config/services.yaml | 2 ++ src/Bundle/ChillMainBundle/Resources/doc/index.rst | 0 .../ChillMainBundle/Resources/public/lib/breadcrumb/index.js | 3 +++ .../ChillMainBundle/Resources/public/lib/export-list/index.js | 1 + .../ChillMainBundle/Resources/public/lib/show_hide/index.js | 1 + .../module/scratch/contrib/bourbon/settings/_px-to-em.scss | 1 + .../ChillMainBundle/Resources/public/module/scratch/index.js | 1 + .../ChillMainBundle/Resources/public/page/login/index.js | 3 +++ .../test/Fixtures/App/app/DoctrineMigrations/.gitignore | 2 ++ .../Resources/test/views/menus/fakeTemplate.html.twig | 1 + .../Resources/views/CRUD/_inc/default.html.twig | 1 + 18 files changed, 22 insertions(+) create mode 100644 src/Bundle/ChillActivityBundle/Resources/doc/index.rst create mode 100644 src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore create mode 100644 src/Bundle/ChillAsideActivityBundle/CHANGELOG.md create mode 100644 src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore create mode 100644 src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/logs/empty create mode 100644 src/Bundle/ChillDocStoreBundle/.gitignore create mode 100644 src/Bundle/ChillEventBundle/Resources/public/chill/index.js create mode 100644 src/Bundle/ChillEventBundle/config/services.yaml create mode 100644 src/Bundle/ChillMainBundle/Resources/doc/index.rst create mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js create mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js create mode 100644 src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js create mode 100644 src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss create mode 100644 src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js create mode 100644 src/Bundle/ChillMainBundle/Resources/public/page/login/index.js create mode 100644 src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore create mode 100644 src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig diff --git a/src/Bundle/ChillActivityBundle/Resources/doc/index.rst b/src/Bundle/ChillActivityBundle/Resources/doc/index.rst new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/src/Bundle/ChillActivityBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/src/Bundle/ChillAsideActivityBundle/CHANGELOG.md b/src/Bundle/ChillAsideActivityBundle/CHANGELOG.md new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/logs/empty b/src/Bundle/ChillCustomFieldsBundle/Resources/test/Fixtures/App/logs/empty new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillDocStoreBundle/.gitignore b/src/Bundle/ChillDocStoreBundle/.gitignore new file mode 100644 index 000000000..57872d0f1 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/.gitignore @@ -0,0 +1 @@ +/vendor/ diff --git a/src/Bundle/ChillEventBundle/Resources/public/chill/index.js b/src/Bundle/ChillEventBundle/Resources/public/chill/index.js new file mode 100644 index 000000000..adb0dd85e --- /dev/null +++ b/src/Bundle/ChillEventBundle/Resources/public/chill/index.js @@ -0,0 +1 @@ +require('./chillevent.scss'); diff --git a/src/Bundle/ChillEventBundle/config/services.yaml b/src/Bundle/ChillEventBundle/config/services.yaml new file mode 100644 index 000000000..8287f32b5 --- /dev/null +++ b/src/Bundle/ChillEventBundle/config/services.yaml @@ -0,0 +1,2 @@ +services: + diff --git a/src/Bundle/ChillMainBundle/Resources/doc/index.rst b/src/Bundle/ChillMainBundle/Resources/doc/index.rst new file mode 100644 index 000000000..e69de29bb diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js new file mode 100644 index 000000000..40173696d --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/breadcrumb/index.js @@ -0,0 +1,3 @@ +require("./layout.scss"); + + diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js new file mode 100644 index 000000000..49e1a5b20 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/export-list/index.js @@ -0,0 +1 @@ +require('./export-list.scss'); diff --git a/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js b/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js new file mode 100644 index 000000000..34f3b80b5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/lib/show_hide/index.js @@ -0,0 +1 @@ +require("./show_hide.js"); \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss b/src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss new file mode 100644 index 000000000..f2f9a3e8d --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/module/scratch/contrib/bourbon/settings/_px-to-em.scss @@ -0,0 +1 @@ +$em-base: 16px !default; diff --git a/src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js b/src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js new file mode 100644 index 000000000..6396103fc --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/module/scratch/index.js @@ -0,0 +1 @@ +require('./scratch.scss'); diff --git a/src/Bundle/ChillMainBundle/Resources/public/page/login/index.js b/src/Bundle/ChillMainBundle/Resources/public/page/login/index.js new file mode 100644 index 000000000..1e6676d8f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/public/page/login/index.js @@ -0,0 +1,3 @@ +require('./login.scss'); + + diff --git a/src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore b/src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/test/Fixtures/App/app/DoctrineMigrations/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig b/src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig new file mode 100644 index 000000000..3b1236389 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/test/views/menus/fakeTemplate.html.twig @@ -0,0 +1 @@ +fake template \ No newline at end of file diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig new file mode 100644 index 000000000..0e9d6dd4c --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_inc/default.html.twig @@ -0,0 +1 @@ +{{ data }} \ No newline at end of file From 88c192c22e574d882d406ee565b2bae54d98cbd3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 9 Sep 2021 17:44:37 +0200 Subject: [PATCH 009/121] change namespace migration --- .../ChillDocStoreBundle/migrations/Version20210903123835.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php index bb5b9d973..ae8c4bd17 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Application\Migrations; +namespace Chill\DocStoreBundle\Migrations; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; From 75aa600a201c04cdbf39750552e0e9adcd13b3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Sep 2021 12:41:55 +0200 Subject: [PATCH 010/121] fix composer.json and upgrade base app --- composer.json | 3 ++- tests/app | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 88e3c520a..04ff52e3d 100644 --- a/composer.json +++ b/composer.json @@ -95,6 +95,7 @@ } }, "config": { - "bin-dir": "bin" + "bin-dir": "bin", + "vendor-dir": "tests/app/vendor" } } diff --git a/tests/app b/tests/app index 8839b431f..bd95d3c96 160000 --- a/tests/app +++ b/tests/app @@ -1 +1 @@ -Subproject commit 8839b431f296733b792c788f2ef58e5ecd6419d3 +Subproject commit bd95d3c96a437757b7e8f35cdfd30da9aeac1a01 From ed31dc3157fb245880e6903ef92a6ad416cc961b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Sep 2021 13:13:17 +0200 Subject: [PATCH 011/121] enable test for calendar --- phpunit.xml.dist | 5 +- .../Controller/CalendarControllerTest.php | 59 +++++++++++-------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 25c5f0ff0..96f7461eb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -10,7 +10,7 @@ - + @@ -31,6 +31,9 @@ src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php + + src/Bundle/ChillCalendarBundle/Tests/ + diff --git a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php index c94238a51..00fca668a 100644 --- a/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php +++ b/src/Bundle/ChillCalendarBundle/Tests/Controller/CalendarControllerTest.php @@ -2,65 +2,72 @@ namespace Chill\CalendarBundle\Tests\Controller; +use Chill\PersonBundle\Repository\AccompanyingPeriodRepository; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; use Symfony\Component\HttpFoundation\Request; use Chill\PersonBundle\Entity\AccompanyingPeriod; class CalendarControllerTest extends WebTestCase { - - /** - * Setup before the first test of this class (see phpunit doc) - */ - public static function setUpBeforeClass() - { - static::bootKernel(); - } /** * Setup before each test method (see phpunit doc) */ public function setUp() { + static::bootKernel(); $this->client = static::createClient(array(), array( 'PHP_AUTH_USER' => 'center a_social', 'PHP_AUTH_PW' => 'password', )); } - - private function getAccompanyingPeriodFromFixtures(): AccompanyingPeriod + + public function provideAccompanyingPeriod(): iterable { - $em = static::$kernel->getContainer() - ->get('doctrine.orm.entity_manager'); + static::bootKernel(); + $em= static::$container->get(EntityManagerInterface::class); - $accompanying_period = $em->getRepository('ChillPersonBundle:AccompanyingPeriod')->find(1); + $nb = $em->createQueryBuilder() + ->from(AccompanyingPeriod::class, 'ac') + ->select('COUNT(ac) AS nb') + ->getQuery() + ->getSingleScalarResult() + ; - if ($accompanying_period === NULL) { - throw new \RuntimeException("We need an accompanying course with id = 1. Did you add fixtures ?"); - } - - return $accompanying_period; + yield [ $em->createQueryBuilder() + ->from(AccompanyingPeriod::class, 'ac') + ->select('ac.id') + ->setFirstResult(\random_int(0, $nb)) + ->setMaxResults(1) + ->getQuery() + ->getSingleScalarResult() + ]; } - public function testList() + /** + * @dataProvider provideAccompanyingPeriod + */ + public function testList(int $accompanyingPeriodId) { $this->client->request( - Request::METHOD_GET, - sprintf('/fr/calendar/?accompanying_period_id=%d', $this->getAccompanyingPeriodFromFixtures()->getId()) + Request::METHOD_GET, + sprintf('/fr/calendar/calendar/?accompanying_period_id=%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } - - public function testNew() + /** + * @dataProvider provideAccompanyingPeriod + */ + public function testNew(int $accompanyingPeriodId) { $this->client->request( - Request::METHOD_GET, - sprintf('/fr/calendar/new?accompanying_period_id=%d', $this->getAccompanyingPeriodFromFixtures()->getId()) + Request::METHOD_GET, + sprintf('/fr/calendar/calendar/new?accompanying_period_id=%d', $accompanyingPeriodId) ); $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } - } From f7cb93fdac337c10c3efd8a57db1c4a2966153cb Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Sep 2021 10:30:52 +0200 Subject: [PATCH 012/121] Update controller and the way they are autoloaded --- .../config/services/controller.yaml | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml index 9899ffa2e..6675102d9 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml @@ -1,11 +1,9 @@ services: - Chill\DocStoreBundle\Controller\: - resource: '../../Controller' - tags: ['controller.service_arguments'] - - Chill\DocStoreBundle\Controller\DocumentPersonController: - arguments: - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' - tags: ['controller.service_arguments'] \ No newline at end of file + _defaults: + autowire: true + autoconfigure: true + + Chill\DocStoreBundle\Controller\: + resource: "../../Controller" + tags: ["controller.service_arguments"] + From 2e5c2de36313339104c453cd54d0d1b9b5b3e3c0 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Sep 2021 15:44:06 +0200 Subject: [PATCH 013/121] Documents can be added/viewed/edited for an accompanyingCourse + menu entry added --- .../DocumentAccompanyingCourseController.php | 47 ++-------- .../Entity/AccompanyingCourseDocument.php | 7 +- .../Form/AccompanyingCourseDocumentType.php | 1 + .../ChillDocStoreBundle/Menu/MenuBuilder.php | 24 ++++- .../AccompanyingCourseDocument/edit.html.twig | 5 +- .../index.html.twig | 11 +-- .../AccompanyingCourseDocument/show.html.twig | 9 +- .../AccompanyingCourseDocumentVoter.php | 94 +++++++++++++++++++ .../ChillDocStoreBundle/config/services.yaml | 11 +-- .../config/services/controller.yaml | 18 +--- .../Menu/AccompanyingCourseMenuBuilder.php | 7 -- 11 files changed, 142 insertions(+), 92 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php diff --git a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php index 5791d1ad9..512747b01 100644 --- a/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php +++ b/src/Bundle/ChillDocStoreBundle/Controller/DocumentAccompanyingCourseController.php @@ -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(); diff --git a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php index 3649bd51c..fd3ba93bc 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/AccompanyingCourseDocument.php @@ -16,12 +16,7 @@ class AccompanyingCourseDocument extends Document * @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class) * @ORM\JoinColumn(nullable=false) */ - private $course; - - public function getId(): ?int - { - return $this->id; - } + private ?AccompanyingPeriod $course = null; public function getCourse(): ?AccompanyingPeriod { diff --git a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php index bdaea7ee0..b1a113a0a 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/AccompanyingCourseDocumentType.php @@ -66,6 +66,7 @@ class AccompanyingCourseDocumentType extends AbstractType 'error_bubbling' => true ]) ->add('date', ChillDateType::class) + //TODO : adapt to using AccompanyingCourseDocument categories. Currently there are none... ->add('category', EntityType::class, array( 'placeholder' => 'Choose a document category', 'class' => 'ChillDocStoreBundle:DocumentCategory', diff --git a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php index 03a8b7038..c48d45833 100644 --- a/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php +++ b/src/Bundle/ChillDocStoreBundle/Menu/MenuBuilder.php @@ -50,6 +50,9 @@ class MenuBuilder implements LocalMenuBuilderInterface public function buildMenu($menuId, MenuItem $menu, array $parameters) { switch($menuId) { + case 'accompanyingCourse': + $this->buildMenuAccompanyingCourse($menu, $parameters); + break; case 'person': $this->buildMenuPerson($menu, $parameters); break; @@ -57,7 +60,7 @@ class MenuBuilder implements LocalMenuBuilderInterface throw new \LogicException("this menuid $menuId is not implemented"); } } - + protected function buildMenuPerson(MenuItem $menu, array $parameters) { /* @var $person \Chill\PersonBundle\Entity\Person */ @@ -80,8 +83,25 @@ class MenuBuilder implements LocalMenuBuilderInterface } + protected function buildMenuAccompanyingCourse(MenuItem $menu, array $parameters){ + $course = $parameters['accompanyingCourse']; + // $user = $this->tokenStorage->getToken()->getUser(); + + //TODO : add condition to check user rights? + + $menu->addChild($this->translator->trans('Documents'), [ + 'route' => 'accompanying_course_document_index', + 'routeParameters' => [ + 'course' => $course->getId() + ] + ]) + ->setExtras([ + 'order'=> 400 + ]); + } + public static function getMenuIds(): array { - return [ 'person' ]; + return [ 'person', 'accompanyingCourse' ]; } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig index e2b0a9559..3ca7291b2 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig @@ -5,7 +5,7 @@ {% block title %} {# {{ 'Editing document for %name%'|trans({ '%name%': accompanyingCourse|chill_entity_render_string } ) }} #} {% endblock %} -{% block accompanyingCoursecontent %} +{% block content %}

    {{ 'Edit Document' | trans }}

    @@ -16,13 +16,12 @@ {{ form_row(form.title) }} {{ form_row(form.date) }} {{ form_row(form.category) }} - {{ form_row(form.scope) }} {{ form_row(form.description) }} {{ form_row(form.object, { 'label': 'Document', 'existing': document.object }) }}
    • - + {{ 'Back to the list' | trans }}
    • diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig index 114dbb342..caf370b47 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -20,7 +20,6 @@ {{ 'Title' | trans }} {{ 'Category'|trans }} - {{ 'Circle' | trans }} {{ 'Actions' | trans }} @@ -32,19 +31,19 @@ {# {{ document.scope.name|localize_translatable_string }} #}
        - {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %} + {# if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) #}
      • {{ m.download_button(document.object, document.title) }}
      • - +
      • - {% endif %} - {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %} + {# endif #} + {# if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) #}
      • - {% endif %} + {# endif #}
      diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig index 901d84540..fba831a3c 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig @@ -13,7 +13,7 @@ {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} -{% block accompanyingCoursecontent %} +{% block content %}

      {{ 'Document %title%' | trans({ '%title%': document.title }) }}

      @@ -21,9 +21,6 @@
      {{ 'Title'|trans }}
      {{ document.title }}
      -
      {{ 'Scope' | trans }}
      -
      {{ document.scope.name | localize_translatable_string }}
      -
      {{ 'Category'|trans }}
      {{ document.category.name|localize_translatable_string }}
      @@ -42,7 +39,7 @@
      • - + {{ 'Back to the list' | trans }}
      • @@ -53,7 +50,7 @@ {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
      • - + {{ 'Edit' | trans }}
      • diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php new file mode 100644 index 000000000..8354e63e7 --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php @@ -0,0 +1,94 @@ +accessDecisionManager = $accessDecisionManager; + $this->authorizationHelper = $authorizationHelper; + $this->logger = $logger; + } + + public function getRoles() + { + return [ + self::CREATE, + self::SEE, + self::SEE_DETAILS, + self::UPDATE, + self::DELETE + ]; + } + + protected function supports($attribute, $subject) + { + if (\in_array($attribute, $this->getRoles()) && $subject instanceof AccompanyingCourseDocument) { + return true; + } + + //if ($subject instanceof AccompanyingPeriod && $attribute === self::CREATE) { + return true; + //} + + return false; + } + + protected function isGranted($attribute, $report, $user = null) + { + if (! $user instanceof User){ + return false; + } + // TODO + // return $this->helper->userHasAccess($user, $report, $attribute); + return true; + } + + public function getRolesWithoutScope() + { + return array(); + } + + + public function getRolesWithHierarchy() + { + return ['accompanyingCourseDocument' => $this->getRoles() ]; + } +} diff --git a/src/Bundle/ChillDocStoreBundle/config/services.yaml b/src/Bundle/ChillDocStoreBundle/config/services.yaml index 232edec3f..2766cb1c7 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services.yaml @@ -21,12 +21,9 @@ services: tags: - { name: form.type, alias: chill_docstorebundle_form_document } - Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter: - class: Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter - arguments: - - "@security.access.decision_manager" - - "@chill.main.security.authorization.helper" - - "@logger" + Chill\DocStoreBundle\Security\Authorization\: + resource: "./../Security/Authorization" + autowire: true + autoconfigure: true tags: - - { name: security.voter } - { name: chill.role } diff --git a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml index 5a6b5a5fc..3e2f8392f 100644 --- a/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml +++ b/src/Bundle/ChillDocStoreBundle/config/services/controller.yaml @@ -1,18 +1,8 @@ services: + _defaults: + autowire: true + autoconfigure: true + Chill\DocStoreBundle\Controller\: resource: "../../Controller" tags: ["controller.service_arguments"] - - Chill\DocStoreBundle\Controller\DocumentPersonController: - arguments: - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' - tags: ["controller.service_arguments"] - - Chill\DocStoreBundle\Controller\DocumentAccompanyingCourseController: - arguments: - $translator: '@Symfony\Component\Translation\TranslatorInterface' - $eventDispatcher: '@Symfony\Component\EventDispatcher\EventDispatcherInterface' - $authorizationHelper: '@Chill\MainBundle\Security\Authorization\AuthorizationHelper' - tags: ["controller.service_arguments"] diff --git a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php index 41de5718d..703bdb1bc 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AccompanyingCourseMenuBuilder.php @@ -61,13 +61,6 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface ]]) ->setExtras(['order' => 30]); - $menu->addChild($this->translator->trans('Documents'), [ - 'route' => 'accompanying_course_document_index', - 'routeParameters' => [ - 'course' => $period->getId() - ]]) - ->setExtras(['order' => 40]); - $menu->addChild($this->translator->trans('Accompanying Course Action'), [ 'route' => 'chill_person_accompanying_period_work_list', 'routeParameters' => [ From e03f41ffbcaf50dff0b3033ec4c6ad5b0d2ecb6e Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Sep 2021 15:56:56 +0200 Subject: [PATCH 014/121] user access rights put back in to place --- .../AccompanyingCourseDocument/index.html.twig | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig index caf370b47..7f97dee1f 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -28,22 +28,21 @@ {{ document.title }} {{ document.category.name|localize_translatable_string }} - {# {{ document.scope.name|localize_translatable_string }} #}
          - {# if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) #} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_SEE_DETAILS', document) %}
        • {{ m.download_button(document.object, document.title) }}
        • - {# endif #} - {# if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) #} + {% endif %} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_UPDATE', document) %}
        • - {# endif #} + {% endif %}
        @@ -57,7 +56,7 @@ - {# {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', accompanyingCourse) %} #} + {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', accompanyingCourse) %} - {# {% endif %} #} + {% endif %} {% endblock %} From d7a4e6c0379b3c30ef69ba7e0bd7d58fed8669d3 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 15 Sep 2021 10:42:56 +0200 Subject: [PATCH 015/121] Banner context fixed parent() passed to template --- .../Resources/views/AccompanyingCourseDocument/edit.html.twig | 1 + .../Resources/views/AccompanyingCourseDocument/index.html.twig | 1 + .../Resources/views/AccompanyingCourseDocument/new.html.twig | 1 + .../Resources/views/AccompanyingCourseDocument/show.html.twig | 1 + 4 files changed, 4 insertions(+) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig index 3ca7291b2..088a351f3 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/edit.html.twig @@ -36,6 +36,7 @@ {% endblock %} {% block js %} + {{ parent() }} {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig index 7f97dee1f..ea003e1ae 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -9,6 +9,7 @@ {% endblock %} {% block js %} + {{ parent() }} {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig index b3b9950ab..713654739 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/new.html.twig @@ -37,6 +37,7 @@ {% endblock %} {% block js %} + {{ parent() }} {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig index fba831a3c..3bf9cac43 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/show.html.twig @@ -10,6 +10,7 @@ {% block js %} + {{ parent() }} {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} From 9ef91eabfbfc8b35286eb54071f8443090443cf5 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Thu, 16 Sep 2021 09:42:46 +0200 Subject: [PATCH 016/121] table style adjusted --- .../index.html.twig | 17 +-- .../views/PersonDocument/index.html.twig | 109 +++++++++--------- 2 files changed, 66 insertions(+), 60 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig index ea003e1ae..fbea1229a 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/AccompanyingCourseDocument/index.html.twig @@ -16,7 +16,8 @@ {% block content %}

        {{ 'Documents' }}

        - +
        + @@ -58,12 +59,12 @@
        {{ 'Title' | trans }}
        {% if is_granted('CHILL_ACCOMPANYING_COURSE_DOCUMENT_CREATE', accompanyingCourse) %} - + {% endif %} {% endblock %} diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig index 662477c99..40c85002e 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/PersonDocument/index.html.twig @@ -21,63 +21,68 @@ {% import "@ChillDocStore/Macro/macro.html.twig" as m %} -{% block title %}{{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}{% endblock %} +{% block title %} + {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }} +{% endblock %} {% block js %} - {{ encore_entry_script_tags('mod_async_upload') }} + {{ encore_entry_script_tags('mod_async_upload') }} {% endblock %} {% block personcontent %} -

        {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}

        +

        {{ 'Documents for %name%'|trans({ '%name%': person|chill_entity_render_string } ) }}

        - - - - - - - - - - - {% for document in documents %} - - - - - - - {% else %} - - - - {% endfor %} - -
        {{ 'Title' | trans }}{{ 'Category'|trans }}{{ 'Circle' | trans }}{{ 'Actions' | trans }}
        {{ document.title }}{{ document.category.name|localize_translatable_string }}{{ document.scope.name|localize_translatable_string }} -
          - {% if is_granted('CHILL_PERSON_DOCUMENT_SEE_DETAILS', document) %} -
        • - {{ m.download_button(document.object, document.title) }} -
        • -
        • - -
        • - {% endif %} - {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %} -
        • - -
        • - {% endif %} -
        -
        {{ 'Any document found'|trans }}
        + - {% if is_granted('CHILL_PERSON_DOCUMENT_CREATE', person) %} - - {% endif %} + + + + + + + + + + {% for document in documents %} + + + + + + + {% else %} + + + + {% endfor %} + +
        {{ 'Title' | trans }}{{ 'Category'|trans }}{{ 'Circle' | trans }}{{ 'Actions' | trans }}
        {{ document.title }}{{ document.category.name|localize_translatable_string }}{{ document.scope.name|localize_translatable_string }} +
          + {% if is_granted('CHILL_PERSON_DOCUMENT_SEE_DETAILS', document) %} +
        • + {{ m.download_button(document.object, document.title) }} +
        • +
        • + +
        • + {% endif %} + {% if is_granted('CHILL_PERSON_DOCUMENT_UPDATE', document) %} +
        • + +
        • + {% endif %} +
        +
        + {{ 'Any document found'|trans }} +
        + + {% if is_granted('CHILL_PERSON_DOCUMENT_CREATE', person) %} + + {% endif %} {% endblock %} From 694213e79af95abbed8e9d43a6953b94fae5ac48 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 23 Sep 2021 15:45:09 +0200 Subject: [PATCH 017/121] household banner: don't limit maximum number of members --- .../Resources/views/Household/banner.html.twig | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/views/Household/banner.html.twig b/src/Bundle/ChillPersonBundle/Resources/views/Household/banner.html.twig index f5348e6be..990a7cdd3 100644 --- a/src/Bundle/ChillPersonBundle/Resources/views/Household/banner.html.twig +++ b/src/Bundle/ChillPersonBundle/Resources/views/Household/banner.html.twig @@ -20,7 +20,7 @@ - {%- for m in members|slice(0, 5) -%} + {%- for m in members -%} @@ -35,12 +35,6 @@ {%- endfor -%} - - {% if members|length > 5 %} - - {{ 'household.and x other persons'|trans({'x': members|length-5}) }} - - {% endif %} {%- endif -%} From ee3776288be03cb5c7fae16dd7cf4a75d366d311 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 23 Sep 2021 15:52:44 +0200 Subject: [PATCH 018/121] vue_accourse, resources bloc: change for flex-bloc placement --- .../Resources/public/vuejs/AccompanyingCourse/App.vue | 3 ++- .../vuejs/AccompanyingCourse/components/Resources.vue | 10 +++++++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue index 797f246fe..d0ad5056f 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue @@ -96,7 +96,8 @@ export default { } & > div { margin: 1em 3em 0; - &.flex-table { + &.flex-table, + &.flex-bloc { margin: 1em 0 0; } } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue index 7cfb85bce..5706fe315 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Resources.vue @@ -10,7 +10,7 @@ -
        +
        + + From f93c13234ab454fceda78358c3c9b5a579c2fb77 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Thu, 23 Sep 2021 16:20:33 +0200 Subject: [PATCH 019/121] accourse stickyNav: insert a component, replace deprecated anchor name by id --- .../public/vuejs/AccompanyingCourse/App.vue | 2 +- .../AccompanyingCourse/components/Comment.vue | 2 +- .../AccompanyingCourse/components/Confirm.vue | 2 +- .../components/CourseLocation.vue | 2 +- .../components/OriginDemand.vue | 2 +- .../components/PersonsAssociated.vue | 2 +- .../components/Referrer.vue | 2 +- .../components/Requestor.vue | 2 +- .../components/Resources.vue | 2 +- .../AccompanyingCourse/components/Scopes.vue | 2 +- .../components/SocialIssue.vue | 2 +- .../components/StickyNav.vue | 46 +++++++++---------- .../components/StickyNav/Item.vue | 6 +-- 13 files changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue index d0ad5056f..e4baa082b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/App.vue @@ -80,7 +80,7 @@ export default { left: -22px; top: 4px; } - a[name^="section"] { + a[id^="section"] { position: absolute; top: -2.5em; // reference for stickNav } diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue index b64d46103..1bff3f44d 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/Comment.vue @@ -1,6 +1,6 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue index 97a286d70..52b538284 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/PersonsAssociated.vue @@ -26,7 +26,7 @@ :id="p.person.id" :value="p.person.id" /> -
        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 550479895..b1da665a7 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -81,7 +81,8 @@ const appMessages = { edit_temporary_address: "Modifier l'adresse temporaire", assign_course_address: "Désigner comme l'adresse du parcours", remove_button: "Enlever l'adresse", - temporary_address_must_be_changed: "Cette adresse est temporaire et devrait être remplacée par celle d'un usager de référence.", + temporary_address_must_be_changed: "Cette adresse est temporaire. Le parcours devrait être localisé auprès d'un usager concerné.", + associate_at_least_one_person_with_one_household_with_address: "Associez au moins un membre du parcours à un ménage, et indiquez une adresse à ce ménage.", sure: "Êtes-vous sûr ?", sure_description: "Voulez-vous faire de cette adresse l'adresse du parcours ?", ok: "Désigner comme adresse du parcours", From 5da332a06ee59213e2bb2f4ff1a7207eaaaaba00 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Mon, 27 Sep 2021 13:14:42 +0200 Subject: [PATCH 037/121] fix error on previous commit, when creating new accourse --- .../vuejs/AccompanyingCourse/components/CourseLocation.vue | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue index 3e6b40c28..7ae25b25c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/components/CourseLocation.vue @@ -135,12 +135,17 @@ export default { return this.accompanyingCourse.participations.filter(p => p.enddate !== null); }, hasNoPersonLocation() { + let addressInParticipations_ = [] this.currentParticipations.forEach(p => { addressInParticipations_.push(this.checkHouseholdAddressForParticipation(p)); }); + const booleanReducer = (previousValue, currentValue) => previousValue || currentValue; - let addressInParticipations = addressInParticipations_.reduce(booleanReducer); + + let addressInParticipations = (addressInParticipations_.length > 0) ? + addressInParticipations_.reduce(booleanReducer) : false; + //console.log(addressInParticipations_, addressInParticipations); return ( this.accompanyingCourse.step !== 'DRAFT' From c791c482484f54069ac116769c4d5eedabe5070c Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 28 Sep 2021 14:06:52 +0200 Subject: [PATCH 038/121] tp: adapt to new ACL interface (wip) --- .../Controller/ThirdPartyController.php | 32 +++++++++---------- .../ThirdPartyACLAwareRepository.php | 23 +++++++++++++ .../ThirdPartyACLAwareRepositoryInterface.php | 16 ++++++++++ .../Security/Voter/ThirdPartyVoter.php | 2 ++ 4 files changed, 57 insertions(+), 16 deletions(-) create mode 100644 src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php create mode 100644 src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepositoryInterface.php diff --git a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php index d16934b18..dff892b99 100644 --- a/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php +++ b/src/Bundle/ChillThirdPartyBundle/Controller/ThirdPartyController.php @@ -66,8 +66,8 @@ class ThirdPartyController extends Controller $this->getUser(), new Role(ThirdPartyVoter::SHOW) ); - - $nbThirdParties = $repository->countByMemberOfCenters($centers); + + $nbThirdParties = $repository->countByMemberOfCenters($centers); // $pagination = $this->paginatorFactory->create($nbThirdParties); $thirdParties = $repository->findByMemberOfCenters( @@ -88,18 +88,18 @@ class ThirdPartyController extends Controller public function newAction(Request $request) { $this->denyAccessUnlessGranted(ThirdPartyVoter::CREATE); - - $centers = $this->authorizationHelper + + /* $centers = $this->authorizationHelper ->getReachableCenters( - $this->getUser(), + $this->getUser(), new Role(ThirdPartyVoter::CREATE) ); - - if (count($centers) === 0) { + + if ($centers === []) { // throw new \LogicException("There should be at least one center reachable " . "if role ".ThirdPartyVoter::CREATE." is granted"); - } - + } */ + $thirdParty = new ThirdParty(); $thirdParty->setCenters(new ArrayCollection($centers)); @@ -141,18 +141,18 @@ class ThirdPartyController extends Controller public function updateAction(ThirdParty $thirdParty, Request $request) { $this->denyAccessUnlessGranted(ThirdPartyVoter::CREATE); - - $centers = $this->authorizationHelper + + /* $centers = $this->authorizationHelper ->getReachableCenters( - $this->getUser(), + $this->getUser(), new Role(ThirdPartyVoter::CREATE) ); - - if (count($centers) === 0) { + + if ($centers === []) { throw new \LogicException("There should be at least one center reachable " . "if role ".ThirdPartyVoter::CREATE." is granted"); - } - + } */ + // we want to keep centers the users has no access to. So we will add them // later if they are removed. (this is a ugly hack but it will works $centersAssociatedNotForUsers = \array_diff( diff --git a/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php new file mode 100644 index 000000000..ff21d18c7 --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Repository/ThirdPartyACLAwareRepository.php @@ -0,0 +1,23 @@ +getUser(); if (!$user instanceof User) { From ca7ba90717da8d9ca9eedc5d527f7528811d3715 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 28 Sep 2021 14:53:00 +0200 Subject: [PATCH 039/121] hotfix: repair creation activity (was an error linked to ListenToActivityCreate) --- .../Event/ListenToActivityCreate.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php index f3c4e7a59..d7073597a 100644 --- a/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php +++ b/src/Bundle/ChillCalendarBundle/Event/ListenToActivityCreate.php @@ -29,17 +29,19 @@ class ListenToActivityCreate $activityData = $request->query->get('activityData'); if (array_key_exists('calendarId', $activityData)) { $calendarId = $activityData['calendarId']; + + // Attach the activity to the calendar + $em = $event->getObjectManager(); + + $calendar = $em->getRepository(\Chill\CalendarBundle\Entity\Calendar::class)->find($calendarId); + $calendar->setActivity($activity); + + $em->persist($calendar); + $em->flush(); } } - // Attach the activity to the calendar - $em = $event->getObjectManager(); - $calendar = $em->getRepository(\Chill\CalendarBundle\Entity\Calendar::class)->find($calendarId); - $calendar->setActivity($activity); - - $em->persist($calendar); - $em->flush(); } } From e72ba4c940da286bbc63f5d942ccb7f4b395f58a Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 28 Sep 2021 15:34:15 +0200 Subject: [PATCH 040/121] bypass ACL restriction --- .../ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php b/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php index a1ce94e25..7b3e4e5b1 100644 --- a/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php +++ b/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php @@ -56,6 +56,8 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy */ protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { + return true; + $user = $token->getUser(); if (!$user instanceof User) { From d5d12c4a17e1f52e797727833ba1e37dfc437601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 28 Sep 2021 15:50:09 +0200 Subject: [PATCH 041/121] fix tests for user controller --- .../Resources/views/User/index.html.twig | 2 +- .../Tests/Controller/UserControllerTest.php | 87 ++++++++++--------- 2 files changed, 49 insertions(+), 40 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index c57d9ed5f..53bd89482 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -10,7 +10,7 @@ {% endblock %} {% block table_entities_tbody %} {% for entity in entities %} - + {% if entity.isEnabled %} diff --git a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php index 1953439dd..0017fbb4e 100644 --- a/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php +++ b/src/Bundle/ChillMainBundle/Tests/Controller/UserControllerTest.php @@ -2,12 +2,17 @@ namespace Chill\MainBundle\Tests\Controller; +use Chill\MainBundle\Entity\User; +use Doctrine\ORM\EntityManagerInterface; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; class UserControllerTest extends WebTestCase { private $client; + private array $toDelete = []; + public function setUp() { self::bootKernel(); @@ -22,18 +27,14 @@ class UserControllerTest extends WebTestCase public function testList() { // get the list - $crawler = $this->client->request('GET', '/fr/admin/user/'); + $crawler = $this->client->request('GET', '/fr/admin/main/user'); $this->assertEquals(200, $this->client->getResponse()->getStatusCode(), - "Unexpected HTTP status code for GET /admin/user/"); - - $link = $crawler->selectLink('Ajouter un nouvel utilisateur')->link(); - $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $link); - $this->assertRegExp('|/fr/admin/user/new$|', $link->getUri()); + "Unexpected HTTP status code for GET /admin/main/user"); } public function testNew() { - $crawler = $this->client->request('GET', '/fr/admin/user/new'); + $crawler = $this->client->request('GET', '/fr/admin/main/user/new'); $username = 'Test_user'. uniqid(); $password = 'Password1234!'; @@ -54,22 +55,15 @@ class UserControllerTest extends WebTestCase $this->assertGreaterThan(0, $crawler->filter('td:contains("Test_user")')->count(), 'Missing element td:contains("Test user")'); - $update = $crawler->selectLink('Modifier')->link(); - - $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $update); - $this->assertRegExp('|/fr/admin/user/[0-9]{1,}/edit$|', $update->getUri()); - //test the auth of the new client $this->isPasswordValid($username, $password); - - return $update; } protected function isPasswordValid($username, $password) { /* @var $passwordEncoder \Symfony\Component\Security\Core\Encoder\UserPasswordEncoder */ - $passwordEncoder = self::$kernel->getContainer() - ->get('security.password_encoder'); + $passwordEncoder = self::$container + ->get(UserPasswordEncoderInterface::class); $user = self::$kernel->getContainer() ->get('doctrine.orm.entity_manager') @@ -81,46 +75,33 @@ class UserControllerTest extends WebTestCase /** * - * @param \Symfony\Component\DomCrawler\Link $update - * @depends testNew + * @dataProvider dataGenerateUserId */ - public function testUpdate(\Symfony\Component\DomCrawler\Link $update) + public function testUpdate(int $userId, string $username) { - $crawler = $this->client->click($update); + $crawler = $this->client->request('GET', "/fr/admin/main/user/$userId/edit"); $username = 'Foo bar '.uniqid(); - $form = $crawler->selectButton('Mettre à jour')->form(array( + $form = $crawler->selectButton('Enregistrer & fermer')->form(array( 'chill_mainbundle_user[username]' => $username, )); $this->client->submit($form); $crawler = $this->client->followRedirect(); // Check the element contains an attribute with value equals "Foo" - $this->assertGreaterThan(0, $crawler->filter('[value="'.$username.'"]')->count(), - 'Missing element [value="Foo bar"]'); - - $updatePassword = $crawler->selectLink('Modifier le mot de passe')->link(); - - $this->assertInstanceOf('Symfony\Component\DomCrawler\Link', $updatePassword); - $this->assertRegExp('|/fr/admin/user/[0-9]{1,}/edit_password$|', - $updatePassword->getUri()); - - return array('link' => $updatePassword, 'username' => $username); + $this->assertGreaterThan(0, $crawler->filter('[data-username="'.$username.'"]')->count(), + 'Missing element [data-username="Foo bar"]'); } /** * - * @param \Symfony\Component\DomCrawler\Link $updatePassword - * @depends testUpdate + * @dataProvider dataGenerateUserId */ - public function testUpdatePassword(array $params) + public function testUpdatePassword(int $userId, $username) { - $link = $params['link']; - $username = $params['username']; + $crawler = $this->client->request('GET', "/fr/admin/user/$userId/edit_password"); $newPassword = '1234Password!'; - $crawler = $this->client->click($link); - $form = $crawler->selectButton('Changer le mot de passe')->form(array( 'chill_mainbundle_user_password[new_password][first]' => $newPassword, 'chill_mainbundle_user_password[new_password][second]' => $newPassword, @@ -130,10 +111,38 @@ class UserControllerTest extends WebTestCase $this->assertTrue($this->client->getResponse()->isRedirect(), "the response is a redirection"); - $this->client->followRedirect(); $this->isPasswordValid($username, $newPassword); } + protected function tearDown() + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + foreach ($this->toDelete as list($class, $id)) { + $obj = $em->getRepository($class)->find($id); + $em->remove($obj); + } + + $em->flush(); + } + + public function dataGenerateUserId() + { + self::bootKernel(); + $em = self::$container->get(EntityManagerInterface::class); + + $user = new User(); + $user->setUsername('Test_user '.uniqid()); + $user->setPassword(self::$container->get(UserPasswordEncoderInterface::class)->encodePassword($user, + 'password')); + + $em->persist($user); + $em->flush(); + + $this->toDelete[] = [User::class, $user->getId()]; + + yield [ $user->getId(), $user->getUsername() ]; + } } From 472866ce91cdb2dc5f5a72967e7ca58ffdfa4cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 28 Sep 2021 15:53:41 +0200 Subject: [PATCH 042/121] fix search by birthdate --- .../ChillPersonBundle/Repository/PersonACLAwareRepository.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php index d15e8cd7a..cd4f8c9ce 100644 --- a/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php +++ b/src/Bundle/ChillPersonBundle/Repository/PersonACLAwareRepository.php @@ -199,7 +199,7 @@ final class PersonACLAwareRepository implements PersonACLAwareRepositoryInterfac } if (NULL !== $birthdate) { - $qb->andWhere($qb->expr()->eq('s.birthdate', ':birthdate')) + $qb->andWhere($qb->expr()->eq('p.birthdate', ':birthdate')) ->setParameter('birthdate', $birthdate); } From e2230409b807eb29b820cf3cc1ac15595e5b2ff3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 28 Sep 2021 15:59:31 +0200 Subject: [PATCH 043/121] remove dump --- src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php index 848e8f874..adc37d5b5 100644 --- a/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php +++ b/src/Bundle/ChillPersonBundle/DataFixtures/ORM/LoadPeople.php @@ -247,7 +247,6 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con if (\random_int(0, 10) > 3) { // always add social scope: $accompanyingPeriod->addScope($this->getReference('scope_social')); - var_dump(count($accompanyingPeriod->getScopes())); $accompanyingPeriod->setAddressLocation($this->createAddress()); $manager->persist($accompanyingPeriod->getAddressLocation()); From 644d0420ceaa5bc485ce9dd0099ff39cc5d0a574 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 28 Sep 2021 16:23:24 +0200 Subject: [PATCH 044/121] creation of endpoints POST, PUT, PATCH, but still errors --- .../ChillThirdPartyExtension.php | 18 +++- .../Entity/ThirdParty.php | 10 +- .../Security/Voter/ThirdPartyVoter.php | 2 + .../chill.api.specs.yaml | 97 ++++++++++++++++++- 4 files changed, 116 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php index 9b23222c6..2fd0f723d 100644 --- a/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php +++ b/src/Bundle/ChillThirdPartyBundle/DependencyInjection/ChillThirdPartyExtension.php @@ -59,7 +59,7 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte 'class' => \Chill\ThirdPartyBundle\Entity\ThirdParty::class, 'name' => 'thirdparty', 'base_path' => '/api/1.0/thirdparty/thirdparty', - 'base_role' => \Chill\ThirdPartyBundle\Security\Authorization\ThirdPartyVoter::class, + //'base_role' => \Chill\ThirdPartyBundle\Security\Authorization\ThirdPartyVoter::SHOW, //'controller' => \Chill\ThirdPartyBundle\Controller\ThirdPartyApiController::class, 'actions' => [ '_index' => [ @@ -67,19 +67,31 @@ class ChillThirdPartyExtension extends Extension implements PrependExtensionInte Request::METHOD_GET => true, Request::METHOD_HEAD => true, Request::METHOD_POST => true, + Request::METHOD_PATCH => true, + Request::METHOD_PUT => true + ], + 'roles' => [ + Request::METHOD_GET => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::SHOW, + Request::METHOD_HEAD => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::SHOW, + Request::METHOD_POST => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::CREATE, + Request::METHOD_PUT => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::CREATE, + Request::METHOD_PATCH => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::CREATE ], ], '_entity' => [ 'methods' => [ Request::METHOD_GET => true, Request::METHOD_HEAD => true, - Request::METHOD_POST=> true, + Request::METHOD_POST => true, + Request::METHOD_PUT => true, + Request::METHOD_PATCH => true ], 'roles' => [ Request::METHOD_GET => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::SHOW, Request::METHOD_HEAD => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::SHOW, Request::METHOD_POST => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::CREATE, - + Request::METHOD_PUT => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::CREATE, + Request::METHOD_PATCH => \Chill\ThirdPartyBundle\Security\Voter\ThirdPartyVoter::CREATE ], ] ] diff --git a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php index 0b0b3e56b..842e57b8b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php +++ b/src/Bundle/ChillThirdPartyBundle/Entity/ThirdParty.php @@ -60,7 +60,7 @@ class ThirdParty * @var string * @ORM\Column(name="name", type="string", length=255) * @Assert\Length(min="2") - * @Groups({"read"}) + * @Groups({"read", "write"}) */ private $name; @@ -69,6 +69,7 @@ class ThirdParty * @var string * @ORM\Column(name="name_company", type="string", length=255, nullable=true) * @Assert\Length(min="3") + * @Groups({"read", "write"}) */ private $nameCompany; @@ -77,6 +78,7 @@ class ThirdParty * @var string * @ORM\Column(name="acronym", type="string", length=64, nullable=true) * @Assert\Length(min="2") + * @Groups({"read", "write"}) */ private $acronym; @@ -130,7 +132,7 @@ class ThirdParty * @Assert\Regex("/^([\+{1}])([0-9\s*]{4,20})$/", * message="Invalid phone number: it should begin with the international prefix starting with ""+"", hold only digits and be smaller than 20 characters. Ex: +33123456789" * ) - * @Groups({"read"}) + * @Groups({"read", "write"}) */ private $telephone; @@ -138,7 +140,7 @@ class ThirdParty * @var string|null * @ORM\Column(name="email", type="string", length=255, nullable=true) * @Assert\Email(checkMX=false) - * @Groups({"read"}) + * @Groups({"read", "write"}) */ private $email; @@ -147,7 +149,7 @@ class ThirdParty * @ORM\ManyToOne(targetEntity="\Chill\MainBundle\Entity\Address", * cascade={"persist", "remove"}) * @ORM\JoinColumn(nullable=true, onDelete="SET NULL") - * @Groups({"read"}) + * @Groups({"read", "write"}) */ private $address; diff --git a/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php b/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php index a1ce94e25..986bfb2b9 100644 --- a/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php +++ b/src/Bundle/ChillThirdPartyBundle/Security/Voter/ThirdPartyVoter.php @@ -61,6 +61,8 @@ class ThirdPartyVoter extends AbstractChillVoter implements ProvideRoleHierarchy if (!$user instanceof User) { return false; } + + return true; $centers = $this->authorizationHelper ->getReachableCenters($user, new Role($attribute)); diff --git a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml index 957bf9324..c5d9346ba 100644 --- a/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml +++ b/src/Bundle/ChillThirdPartyBundle/chill.api.specs.yaml @@ -8,17 +8,47 @@ servers: - url: "/api" description: "Your current dev server" +components: + schemas: + Thirdparty: + type: object + properties: + id: + type: integer + readOnly: true + name: + type: string + nameCompany: + type: string + acronym: + type: string + email: + type: string + paths: /1.0/thirdparty/thirdparty.json: - get: + post: tags: - thirdparty - summary: Return a list of all thirdparty items + summary: Create a single thirdparty + requestBody: + description: "A thirdparty" + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Thirdparty" responses: 200: - description: "ok" - 401: + description: "OK" + content: + application/json: + schema: + $ref: "#/components/schemas/Thirdparty" + 403: description: "Unauthorized" + 422: + description: "Invalid data" /1.0/thirdparty/thirdparty/{id}.json: get: @@ -41,3 +71,62 @@ paths: description: "not found" 401: description: "Unauthorized" + patch: + tags: + - thirdparty + summary: "Alter a thirdparty" + parameters: + - name: id + in: path + required: true + description: The thirdparty's id + schema: + type: integer + format: integer + minimum: 1 + requestBody: + description: "A thirdparty" + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Thirdparty" + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 422: + description: "Object with validation errors" + put: + tags: + - thirdparty + summary: Edit an existing thirdparty + parameters: + - name: id + in: path + required: true + description: The thirdparty's id + schema: + type: integer + format: integer + minimum: 1 + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/Thirdparty" + responses: + 401: + description: "Unauthorized" + 404: + description: "Not found" + 200: + description: "OK" + 422: + description: "Unprocessable entity (validation errors)" + 400: + description: "Bad Request" From c5fa1b883cd355ebe7d1c6dd06fd76ae84b2b3f8 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 28 Sep 2021 16:25:38 +0200 Subject: [PATCH 045/121] onthefly: adding tp i18n file --- .../public/vuejs/AccompanyingCourse/js/i18n.js | 5 +++-- .../public/vuejs/_components/OnTheFly/ThirdParty.vue | 9 ++------- .../Resources/public/vuejs/_js/i18n.js | 11 +++++++++++ 3 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js 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 cf3a0fb7e..0ab012954 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/js/i18n.js @@ -1,4 +1,5 @@ -import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n' +import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'; +import { thirdpartyMessages } from 'ChillThirdPartyAssets/vuejs/_js/i18n'; import { addressMessages } from 'ChillMainAssets/vuejs/Address/i18n'; const appMessages = { @@ -137,7 +138,7 @@ const appMessages = { } }; -Object.assign(appMessages.fr, personMessages.fr, addressMessages.fr); +Object.assign(appMessages.fr, personMessages.fr, thirdpartyMessages.fr, addressMessages.fr); export { appMessages diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 1b1207131..6d1497e2b 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -19,15 +19,10 @@
        - -
        - - -
        - - + +
        diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js new file mode 100644 index 000000000..37d09320d --- /dev/null +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_js/i18n.js @@ -0,0 +1,11 @@ +const thirdpartyMessages = { + fr: { + thirdparty: { + name: "Dénomination", + email: "Courriel", + phonenumber: "Téléphone", + } + } +}; + +export { thirdpartyMessages }; From adc94aaeea34a9e46f7c4738cddcdee307ee3322 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Tue, 28 Sep 2021 16:26:32 +0200 Subject: [PATCH 046/121] javascript syntax correction --- .../vuejs/_components/Entity/PersonRenderBox.vue | 6 +++--- .../vuejs/_components/Entity/ThirdPartyRenderBox.vue | 12 ++++++------ .../public/vuejs/_components/OnTheFly/ThirdParty.vue | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue index 0f397211e..2bc5f0b3b 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/Entity/PersonRenderBox.vue @@ -27,7 +27,7 @@
        -

        +

        - + {{ thirdparty.text }} {{ thirdparty.text }} {{ thirdparty.id }} - {{ $t('renderbox.type.thirdparty') }} + {{ $t('renderbox.type.thirdparty') }}
        -

        +

        @@ -80,10 +80,10 @@ export default { } }, getGender: function() { - return this.thirdparty.gender == 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man'; + return this.thirdparty.gender === 'woman' ? 'renderbox.birthday.woman' : 'renderbox.birthday.man'; }, getGenderIcon: function() { - return this.thirdparty.gender == 'woman' ? 'fa-venus' : this.thirdparty.gender == 'man' ? 'fa-mars' : 'fa-neuter'; + return this.thirdparty.gender === 'woman' ? 'fa-venus' : this.thirdparty.gender === 'man' ? 'fa-mars' : 'fa-neuter'; }, birthdate: function(){ var date = new Date(this.thirdparty.birthdate.datetime); diff --git a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue index 6d1497e2b..016db598c 100644 --- a/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue +++ b/src/Bundle/ChillThirdPartyBundle/Resources/public/vuejs/_components/OnTheFly/ThirdParty.vue @@ -1,5 +1,5 @@ diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js index 5784e8d4c..b66f4d957 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourse/store/index.js @@ -48,7 +48,7 @@ let initPromise = Promise.all([scopesPromise, accompanyingCoursePromise]) return state.accompanyingCourse.location !== null; }, isScopeValid(state) { - console.log('is scope valid', state.accompanyingCourse.scopes.length > 0); + //console.log('is scope valid', state.accompanyingCourse.scopes.length > 0); return state.accompanyingCourse.scopes.length > 0; }, validationKeys(state, getters) { diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue index 160d5d00b..a0e8fbebf 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/_components/AddPersons.vue @@ -229,7 +229,7 @@ export default { return item.result.type + item.result.id; }, addPriorSuggestion() { - console.log('echo', this.hasPriorSuggestion); + //console.log('addPriorSuggestion', this.hasPriorSuggestion); if (this.hasPriorSuggestion) { console.log('addPriorSuggestion',); this.suggested.unshift(this.priorSuggestion); From 0fe248320dbeb86da63736e817b942a0604b2bf4 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Wed, 29 Sep 2021 11:21:45 +0200 Subject: [PATCH 060/121] OnTheFly (otf): fix clickable radio tab on create modal --- .../Resources/public/vuejs/_components/OnTheFly/Create.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue index 3ffb3f7df..7644043fd 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/_components/OnTheFly/Create.vue @@ -3,7 +3,7 @@
      {{ form_end(form) }} - {% endif %} - {% endif %}

      {{ 'household.Household members'|trans }}

      From fbd17a1de62f60394ef4cddd138ac25f55d87573 Mon Sep 17 00:00:00 2001 From: Mathieu Jaumotte Date: Fri, 1 Oct 2021 17:38:19 +0200 Subject: [PATCH 116/121] OnTheFly: adding displayBadge option to replace button by badge When using displayBadge=true, you need to pass buttonText=string with badge content. Limitation: onTheFly cannot use directly PersonRenderBox to display badge, because it don't have person object in props ! --- .../Resources/public/vuejs/OnTheFly/App.vue | 1 + .../vuejs/OnTheFly/components/OnTheFly.vue | 18 ++++++++++--- .../Resources/public/vuejs/OnTheFly/index.js | 5 ++-- .../OnTheFly/_insert_vue_onthefly.html.twig | 27 ++++++++++++++----- .../AccompanyingCourse/_concerned.html.twig | 17 ------------ .../views/AccompanyingCourse/index.html.twig | 12 ++++++++- 6 files changed, 50 insertions(+), 30 deletions(-) delete mode 100644 src/Bundle/ChillPersonBundle/Resources/views/AccompanyingCourse/_concerned.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue index 63c1ad5bd..c4c014e19 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/App.vue @@ -4,6 +4,7 @@ :id="context.id" :action="context.action" :buttonText="options.buttonText" + :displayBadge="options.displayBadge === 'true'" @saveFormOnTheFly="saveFormOnTheFly"> diff --git a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue index 7cfb04651..237166e62 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue +++ b/src/Bundle/ChillMainBundle/Resources/public/vuejs/OnTheFly/components/OnTheFly.vue @@ -1,6 +1,11 @@