From c51b129a5e1f5dacb83f84a7a0da00ab792565cc Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 3 Sep 2021 11:02:56 +0200 Subject: [PATCH 01/27] 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 02/27] 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 03/27] 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 04/27] 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 05/27] 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 06/27] 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 07/27] 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 08/27] 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 09/27] 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 2e5c2de36313339104c453cd54d0d1b9b5b3e3c0 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Tue, 14 Sep 2021 15:44:06 +0200 Subject: [PATCH 10/27] 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 11/27] 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 12/27] 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 13/27] 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 b5c2dd7bd23ab8a529ef641137066268ca7e87f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Wed, 22 Sep 2021 18:18:49 +0200 Subject: [PATCH 14/27] fix-admin and crudify user admin --- .../Controller/AdminController.php | 32 +++------ .../Controller/UserController.php | 62 ++++++----------- .../ChillMainExtension.php | 25 ++++++- .../layout_crud_permission_index.html.twig | 8 +++ .../Resources/views/Admin/index.html.twig | 22 +++--- .../Admin/layoutWithVerticalMenu.html.twig | 31 ++------- .../views/Admin/layout_permissions.html.twig | 6 +- .../views/Admin/menu_admin_index.html.twig | 18 +++++ .../menu_admin_permissions.html.twig} | 0 .../menu_admin_section.html.twig} | 0 .../views/Menu/verticalMenu.html.twig | 16 ++--- .../Resources/views/User/index.html.twig | 67 +++++++++++++++++-- .../MenuBuilder/AdminSectionMenuBuilder.php | 13 ++-- .../MenuBuilder/PermissionMenuBuilder.php | 47 +++++++++++++ src/Bundle/ChillMainBundle/config/routes.yaml | 18 ++--- .../ChillMainBundle/config/routes/center.yaml | 10 --- .../config/routes/permissionsgroup.yaml | 14 +--- .../ChillMainBundle/config/routes/scope.yaml | 10 --- .../ChillMainBundle/config/routes/user.yaml | 18 ++--- .../config/services/controller.yaml | 6 +- .../ChillMainBundle/config/services/menu.yaml | 9 ++- 21 files changed, 247 insertions(+), 185 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig rename src/Bundle/ChillMainBundle/Resources/views/{Menu/admin_permissions.html.twig => Admin/menu_admin_permissions.html.twig} (100%) rename src/Bundle/ChillMainBundle/Resources/views/{Menu/adminSection.html.twig => Admin/menu_admin_section.html.twig} (100%) create mode 100644 src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php diff --git a/src/Bundle/ChillMainBundle/Controller/AdminController.php b/src/Bundle/ChillMainBundle/Controller/AdminController.php index cdb7796a3..1c6569eea 100644 --- a/src/Bundle/ChillMainBundle/Controller/AdminController.php +++ b/src/Bundle/ChillMainBundle/Controller/AdminController.php @@ -23,32 +23,22 @@ namespace Chill\MainBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; -/** - * Class AdminController - * - * @package Chill\MainBundle\Controller - * @author julien.fastre@champs-libres.coop - * @author marc@champs-libres.coop - */ +use Symfony\Component\Routing\Annotation\Route; + class AdminController extends AbstractController { - - public function indexAction($menu = 'admin', - $header_title = 'views.Main.admin.index.header_title', - $page_title = 'views.Main.admin.index.page_title') { - return $this->render('@ChillMain/Admin/layout.html.twig'); + + /** + * @Route("/{_locale}/admin", name="chill_main_admin_central") + */ + public function indexAction() + { + return $this->render('@ChillMain/Admin/index.html.twig'); } - + public function indexPermissionsAction() { return $this->render('@ChillMain/Admin/layout_permissions.html.twig'); } - - public function configurationWarningsAction() - { - $alertManager = $this->get('chill_main.configuration_alert_manager'); - - - } - + } diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 7de280d1d..62a28b8d6 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -2,6 +2,8 @@ namespace Chill\MainBundle\Controller; +use Chill\MainBundle\CRUD\Controller\AbstractCRUDController; +use Chill\MainBundle\CRUD\Controller\CRUDController; use Psr\Log\LoggerInterface; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Request; @@ -11,6 +13,9 @@ use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Form\Type\ComposedGroupCenterType; use Chill\MainBundle\Form\UserPasswordType; +use Symfony\Component\HttpFoundation\Response; +use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; +use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; @@ -19,69 +24,61 @@ use Symfony\Component\Validator\Validator\ValidatorInterface; * * @package Chill\MainBundle\Controller */ -class UserController extends AbstractController +class UserController extends CRUDController { const FORM_GROUP_CENTER_COMPOSED = 'composed_groupcenter'; - + /** * @var \Psr\Log\LoggerInterface */ private $logger; - + /** * @var ValidatorInterface */ private $validator; - + + private UserPasswordEncoderInterface $passwordEncoder; + /** * UserController constructor. * * @param LoggerInterface $logger * @param ValidatorInterface $validator */ - public function __construct(LoggerInterface $logger, ValidatorInterface $validator) - { + public function __construct( + LoggerInterface $logger, + ValidatorInterface $validator, + UserPasswordEncoderInterface $passwordEncoder + ) { $this->logger = $logger; $this->validator = $validator; + $this->passwordEncoder = $passwordEncoder; } - - /** - * Lists all User entities. - * - */ - public function indexAction() - { - $em = $this->getDoctrine()->getManager(); - $entities = $em->createQuery('SELECT u FROM ChillMainBundle:User u ' - . 'ORDER BY u.username') - ->getResult(); - - return $this->render('@ChillMain/User/index.html.twig', array( - 'entities' => $entities, - )); - } /** * Creates a new User entity. * */ - public function createAction(Request $request) + public function new(Request $request): Response { $user = new User(); $form = $this->createCreateForm($user); $form->handleRequest($request); - if ($form->isValid()) { + if ($form->isSubmitted() && $form->isValid()) { $em = $this->getDoctrine()->getManager(); - $user->setPassword($this->get('security.password_encoder') + $user->setPassword($this->passwordEncoder ->encodePassword($user, $form['plainPassword']->getData())); $em->persist($user); $em->flush(); return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId()))); + } elseif ($form->isSubmitted() && !$form->isValid()){ + } return $this->render('@ChillMain/User/new.html.twig', array( @@ -110,21 +107,6 @@ class UserController extends AbstractController return $form; } - /** - * Displays a form to create a new User entity. - * - */ - public function newAction() - { - $user = new User(); - $form = $this->createCreateForm($user); - - return $this->render('@ChillMain/User/new.html.twig', array( - 'entity' => $user, - 'form' => $form->createView(), - )); - } - /** * Finds and displays a User entity. * diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index d0aada689..65b8ffdf6 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -19,10 +19,13 @@ namespace Chill\MainBundle\DependencyInjection; +use Chill\MainBundle\Controller\UserController; use Chill\MainBundle\Doctrine\DQL\STContains; use Chill\MainBundle\Doctrine\DQL\StrictWordSimilarityOPS; +use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Form\UserJobType; +use Chill\MainBundle\Form\UserType; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\Config\FileLocator; use Symfony\Component\HttpKernel\DependencyInjection\Extension; @@ -283,13 +286,33 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'template' => '@ChillMain/UserJob/index.html.twig', ], 'new' => [ - 'role' => 'ROLE_ADMIN' + 'role' => 'ROLE_ADMIN' ], 'edit' => [ 'role' => 'ROLE_ADMIN' ] ], ], + [ + 'class' => User::class, + 'controller' => UserController::class, + 'name' => 'admin_user', + 'base_path' => '/admin/main/user2', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => UserType::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/User/index.html.twig' + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + ] + ] + ] ], 'apis' => [ [ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig new file mode 100644 index 000000000..76c1e2338 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/Permission/layout_crud_permission_index.html.twig @@ -0,0 +1,8 @@ +{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} + +{% block title %}{{ ('crud.' ~ crud_name ~ '.index.title')|trans({'%crud_name%': crud_name}) }}{% endblock %} + +{% block content %} +{% embed '@ChillMain/CRUD/_index.html.twig' %} +{% endembed %} +{% endblock content %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig index 7c922f333..11d5cc3c9 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/index.html.twig @@ -1,17 +1,15 @@ {% extends "@ChillMain/Admin/layoutWithVerticalMenu.html.twig" %} +{% block vertical_menu_content %} +{% endblock %} + {% block admin_content %}

        {{ 'Administration interface'|trans }}

        - - {{ 'welcome_message_raw'|trans|raw }} -
        -

        {{ 'Configuration alerts'|trans }}

        - -

        {{ 'Here you can check the configuration of your instance.'|trans }}

        - - {{ chill_widget('configuration_warnings', {}) }} - -
        - -{% endblock %} \ No newline at end of file +

        {{ 'Welcome to the admin section !'|trans }}

        + + {{ chill_menu('admin_index', { + 'layout': '@ChillMain/Admin/menu_admin_index.html.twig' + }) }} + +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig index eb9ad8451..9a57b9067 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layoutWithVerticalMenu.html.twig @@ -1,37 +1,14 @@ -{# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, - / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} - -{# - The layout of the admin section. All the page / template of the admin section must use this - layout. -#} - {% extends "@ChillMain/layoutWithVerticalMenu.html.twig" %} {% block navigation_search_bar %}{% endblock %} {% block navigation_section_menu %} {{ chill_menu('admin_section', { - 'layout': '@ChillMain/Menu/adminSection.html.twig', + 'layout': '@ChillMain/Admin/menu_admin_section.html.twig', }) }} {% endblock %} {% block layout_wvm_content %} - {% block admin_content %} -

        {{ 'Welcome to the admin section !'|trans }}

        + {% block admin_content %} + {% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig index 3195ffdb9..dfb5139d3 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout_permissions.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -20,7 +20,7 @@ {% block vertical_menu_content %} {{ chill_menu('admin_permissions', { - 'layout': '@ChillMain/Menu/admin_permissions.html.twig', + 'layout': '@ChillMain/Admin/menu_admin_permissions.html.twig', }) }} {% endblock %} @@ -28,4 +28,4 @@ {% block admin_content %}

        {{ 'Permissions management of your chill installation' |trans }}

        {% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig new file mode 100644 index 000000000..b766b6440 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_index.html.twig @@ -0,0 +1,18 @@ + diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/admin_permissions.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_permissions.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Menu/admin_permissions.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_permissions.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/adminSection.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_section.html.twig similarity index 100% rename from src/Bundle/ChillMainBundle/Resources/views/Menu/adminSection.html.twig rename to src/Bundle/ChillMainBundle/Resources/views/Admin/menu_admin_section.html.twig diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig index 398f84c31..56b2f31ee 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/verticalMenu.html.twig @@ -1,5 +1,5 @@ {# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, / * * This program is free software: you can redistribute it and/or modify @@ -17,7 +17,7 @@ #} {# - Layout for a vertical menu (like admin, export) to use with the + Layout for a vertical menu (like admin, export) to use with the layout ../layoutWithVerticalMenu.html.twig. #} @@ -25,13 +25,9 @@
      • {% block v_menu_title %}{% endblock %}
      • - {% for route in routes %} -
      • - {{ route.label|trans }} + {% for menu in menus %} +
      • {% endfor %} -
      \ No newline at end of file +
    diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index c97a658bb..be8a02d87 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -1,9 +1,66 @@ -{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} - -{% block title %}{{ 'user list'|trans|capitalize }}{% endblock %} +{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block admin_content -%} -

    {{ 'user list'|trans|capitalize }}

    + {% embed '@ChillMain/CRUD/_index.html.twig' %} + {% block table_entites_thead_tr %} + {{ 'crud.admin_user.index.is_active'|trans }} + {{ 'crud.admin_user.index.usernames'|trans }} + {{ 'crud.admin_user.index.mains'|trans }} +   + {% endblock %} + {% block table_entities_tbody %} + {% for entity in entities %} + + + {% if entity.isEnabled %} + + {% else %} + + {% endif %} + + + {{ entity.username }} +
    + {{ entity.label }} +
    + {{ entity.email }} + + + {% if entity.userJob %} + {{ entity.userJob.label|localize_translatable_string }} +
    + {% endif %} + {% if entity.mainScope %} + {{ entity.mainScope.name|localize_translatable_string }} +
    + {% endif %} + {% if entity.mainCenter %} + {{ entity.mainCenter.name }} + {% endif %} + + + + + + + {% endfor %} + {% endblock %} + {% endembed %} +{% endblock %} + +{# @@ -51,3 +108,5 @@ {% endblock admin_content %} + +#} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php index 96a63ff75..b943ce8da 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/AdminSectionMenuBuilder.php @@ -23,7 +23,7 @@ use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface; use Chill\MainBundle\Security\Authorization\ChillExportVoter; /** - * + * * */ class AdminSectionMenuBuilder implements LocalMenuBuilderInterface @@ -33,30 +33,31 @@ class AdminSectionMenuBuilder implements LocalMenuBuilderInterface * @var AuthorizationCheckerInterface */ protected $authorizationChecker; - + public function __construct(AuthorizationCheckerInterface $authorizationChecker) { $this->authorizationChecker = $authorizationChecker; } - + public function buildMenu($menuId, MenuItem $menu, array $parameters) { // all the entries below must have ROLE_ADMIN permissions if (!$this->authorizationChecker->isGranted('ROLE_ADMIN')) { return; } - + $menu->addChild('Users and permissions', [ 'route' => 'chill_main_admin_permissions' ]) ->setExtras([ 'icons' => ['key'], - 'order' => 200 + 'order' => 200, + 'explain' => "Configure permissions for users" ]); } public static function getMenuIds(): array { - return [ 'admin_section' ]; + return [ 'admin_section', 'admin_index' ]; } } diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php new file mode 100644 index 000000000..76cae45f5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php @@ -0,0 +1,47 @@ +addChild('Permissions group list', [ + 'route' => 'admin_permissionsgroup' + ])->setExtras([ + 'order' => 300 + ]); + + $menu->addChild('List users', [ + 'route' => 'admin_user' + ])->setExtras(['order' => 400]); + + $menu->addChild('List users CRUD', [ + 'route' => 'chill_crud_admin_user_index' + ])->setExtras(['order' => 400]); + + $menu->addChild('List circles', [ + 'route' => 'admin_scope' + ])->setExtras(['order' => 200]); + + $menu->addChild('Center list', [ + 'route' => 'admin_center' + ])->setExtras(['order' => 100]); + + $menu->addChild('User jobs', [ + 'route' => 'chill_crud_admin_user_job_index' + ])->setExtras(['order' => 150]); + + } +} diff --git a/src/Bundle/ChillMainBundle/config/routes.yaml b/src/Bundle/ChillMainBundle/config/routes.yaml index 697ec8ec0..d75e91363 100644 --- a/src/Bundle/ChillMainBundle/config/routes.yaml +++ b/src/Bundle/ChillMainBundle/config/routes.yaml @@ -57,15 +57,15 @@ chill_main_homepage: path: /{_locale}/homepage controller: Chill\MainBundle\Controller\DefaultController::indexAction -chill_main_admin_central: - path: /{_locale}/admin - controller: Chill\MainBundle\Controller\AdminController::indexAction - options: - menus: - admin_permissions: - order: 0 - label: Main admin menu - +# chill_main_admin_central: +# path: /{_locale}/admin +# controller: Chill\MainBundle\Controller\AdminController::indexAction +# options: +# menus: +# admin_permissions: +# order: 0 +# label: Main admin menu +# chill_main_admin_permissions: path: /{_locale}/admin/permissions controller: Chill\MainBundle\Controller\AdminController::indexPermissionsAction diff --git a/src/Bundle/ChillMainBundle/config/routes/center.yaml b/src/Bundle/ChillMainBundle/config/routes/center.yaml index 69b635cad..9dc322bc1 100644 --- a/src/Bundle/ChillMainBundle/config/routes/center.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/center.yaml @@ -1,11 +1,6 @@ admin_center: path: / controller: Chill\MainBundle\Controller\CenterController::indexAction - options: - menus: - admin_permissions: - order: 100 - label: Center list admin_center_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_center_show: admin_center_new: path: /new controller: Chill\MainBundle\Controller\CenterController::newAction - options: - menus: - admin_permissions: - order: 101 - label: New center admin_center_create: path: /create diff --git a/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml b/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml index 42e3ea3c2..56f3a7569 100644 --- a/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/permissionsgroup.yaml @@ -1,11 +1,6 @@ admin_permissionsgroup: path: / controller: Chill\MainBundle\Controller\PermissionsGroupController::indexAction - options: - menus: - admin_permissions: - order: 300 - label: Permissions group list admin_permissionsgroup_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_permissionsgroup_show: admin_permissionsgroup_new: path: /new controller: Chill\MainBundle\Controller\PermissionsGroupController::newAction - options: - menus: - admin_permissions: - order: 301 - label: New permission group admin_permissionsgroup_create: path: /create @@ -33,12 +23,12 @@ admin_permissionsgroup_update: path: /{id}/update controller: Chill\MainBundle\Controller\PermissionsGroupController::updateAction methods: [POST, PUT] - + admin_permissionsgroup_delete_role_scope: path: /{pgid}/delete_link_role_scope/{rsid} controller: Chill\MainBundle\Controller\PermissionsGroupController::deleteLinkRoleScopeAction methods: [DELETE] - + admin_permissionsgroup_add_role_scope: path: /{id}/add_link_role_scope controller: Chill\MainBundle\Controller\PermissionsGroupController::addLinkRoleScopeAction diff --git a/src/Bundle/ChillMainBundle/config/routes/scope.yaml b/src/Bundle/ChillMainBundle/config/routes/scope.yaml index cb27ec93b..c7ea32718 100644 --- a/src/Bundle/ChillMainBundle/config/routes/scope.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/scope.yaml @@ -1,11 +1,6 @@ admin_scope: path: / controller: Chill\MainBundle\Controller\ScopeController::indexAction - options: - menus: - admin_permissions: - order: 200 - label: List circles admin_scope_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_scope_show: admin_scope_new: path: /new controller: Chill\MainBundle\Controller\ScopeController::newAction - options: - menus: - admin_permissions: - order: 201 - label: New circle admin_scope_create: path: /create diff --git a/src/Bundle/ChillMainBundle/config/routes/user.yaml b/src/Bundle/ChillMainBundle/config/routes/user.yaml index 545496138..de62a570e 100644 --- a/src/Bundle/ChillMainBundle/config/routes/user.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/user.yaml @@ -1,11 +1,6 @@ admin_user: path: / controller: Chill\MainBundle\Controller\UserController::indexAction - options: - menus: - admin_permissions: - order: 400 - label: List users admin_user_show: path: /{id}/show @@ -14,11 +9,6 @@ admin_user_show: admin_user_new: path: /new controller: Chill\MainBundle\Controller\UserController::newAction - options: - menus: - admin_permissions: - order: 401 - label: Add a new user admin_user_create: path: /create @@ -28,7 +18,7 @@ admin_user_create: admin_user_edit: path: /{id}/edit controller: Chill\MainBundle\Controller\UserController::editAction - + admin_user_edit_password: path: /{id}/edit_password controller: Chill\MainBundle\Controller\UserController::editPasswordAction @@ -37,17 +27,17 @@ admin_user_update: path: /{id}/update controller: Chill\MainBundle\Controller\UserController::updateAction methods: [POST, PUT] - + admin_user_update_password: path: /{id}/update_password controller: Chill\MainBundle\Controller\UserController::updatePasswordAction methods: [POST, PUT] - + admin_user_delete_group_center: path: /{uid}/delete_link_groupcenter/{gcid} controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction methods: [DELETE] - + admin_user_add_group_center: path: /{uid}/add_link_groupcenter controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction diff --git a/src/Bundle/ChillMainBundle/config/services/controller.yaml b/src/Bundle/ChillMainBundle/config/services/controller.yaml index 11a9bc274..a74755ffd 100644 --- a/src/Bundle/ChillMainBundle/config/services/controller.yaml +++ b/src/Bundle/ChillMainBundle/config/services/controller.yaml @@ -29,10 +29,8 @@ services: tags: ['controller.service_arguments'] Chill\MainBundle\Controller\UserController: - arguments: - $logger: '@Psr\Log\LoggerInterface' - $validator: '@Symfony\Component\Validator\Validator\ValidatorInterface' - tags: ['controller.service_arguments'] + autowire: true + autoconfigure: true Chill\MainBundle\Controller\NotificationController: arguments: diff --git a/src/Bundle/ChillMainBundle/config/services/menu.yaml b/src/Bundle/ChillMainBundle/config/services/menu.yaml index 91b481b51..cf31dccf1 100644 --- a/src/Bundle/ChillMainBundle/config/services/menu.yaml +++ b/src/Bundle/ChillMainBundle/config/services/menu.yaml @@ -1,17 +1,22 @@ services: + Chill\MainBundle\Routing\MenuBuilder\: + resource: '../../Routing/MenuBuilder' + autowire: true + autoconfigure: true + Chill\MainBundle\Routing\MenuBuilder\UserMenuBuilder: arguments: $tokenStorage: '@Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface' tags: - { name: 'chill.menu_builder' } - + Chill\MainBundle\Routing\MenuBuilder\SectionMenuBuilder: arguments: $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' $translator: '@Symfony\Component\Translation\TranslatorInterface' tags: - { name: 'chill.menu_builder' } - + Chill\MainBundle\Routing\MenuBuilder\AdminSectionMenuBuilder: arguments: $authorizationChecker: '@Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface' From 72b1916da84eca6953e22476fd076854ac4e29bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Sep 2021 13:30:04 +0200 Subject: [PATCH 15/27] continue CRUD user --- .../CRUD/Controller/CRUDController.php | 15 +- .../Controller/UserController.php | 290 ++++++------------ .../ChillMainExtension.php | 2 + src/Bundle/ChillMainBundle/Form/UserType.php | 10 +- .../views/CRUD/_edit_content.html.twig | 18 +- .../views/CRUD/_new_content.html.twig | 8 +- .../Resources/views/User/edit.html.twig | 111 +++---- .../views/User/edit_password.html.twig | 28 +- .../Resources/views/User/index.html.twig | 57 +--- .../Resources/views/User/new.html.twig | 23 +- .../MenuBuilder/PermissionMenuBuilder.php | 4 - .../ChillMainBundle/config/routes/user.yaml | 88 +++--- 12 files changed, 231 insertions(+), 423 deletions(-) diff --git a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php index adc0c071d..d135cda39 100644 --- a/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php +++ b/src/Bundle/ChillMainBundle/CRUD/Controller/CRUDController.php @@ -118,7 +118,7 @@ class CRUDController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->onFormValid($entity, $form, $request); + $this->onFormValid($action, $entity, $form, $request); $em = $this->getDoctrine()->getManager(); $this->onPreRemove($action, $entity, $form, $request); @@ -607,7 +607,7 @@ class CRUDController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->onFormValid($entity, $form, $request); + $this->onFormValid($action, $entity, $form, $request); $em = $this->getDoctrine()->getManager(); $this->onPreFlush($action, $entity, $form, $request); @@ -706,7 +706,7 @@ class CRUDController extends AbstractController $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { - $this->onFormValid($entity, $form, $request); + $this->onFormValid($action, $entity, $form, $request); $em = $this->getDoctrine()->getManager(); $this->onPrePersist($action, $entity, $form, $request); @@ -716,7 +716,7 @@ class CRUDController extends AbstractController $this->onPreFlush($action, $entity, $form, $request); $em->flush(); $this->onPostFlush($action, $entity, $form, $request); - $this->getPaginatorFactory(); + $this->addFlash('success', $this->generateFormSuccessMessage($action, $entity)); $result = $this->onBeforeRedirectAfterSubmission($action, $entity, $form, $request); @@ -1084,12 +1084,7 @@ class CRUDController extends AbstractController return null; } - /** - * @param object $entity - * @param FormInterface $form - * @param Request $request - */ - protected function onFormValid(object $entity, FormInterface $form, Request $request) + protected function onFormValid(string $action, object $entity, FormInterface $form, Request $request) { } diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 62a28b8d6..99de70747 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -4,8 +4,10 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\AbstractCRUDController; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; -use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; +use Symfony\Component\Form\FormInterface; +use Symfony\Component\HttpFoundation\RedirectResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Form\Extension\Core\Type\SubmitType; use Chill\MainBundle\Entity\User; @@ -13,10 +15,10 @@ use Chill\MainBundle\Form\UserType; use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Form\Type\ComposedGroupCenterType; use Chill\MainBundle\Form\UserPasswordType; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\Security\Core\Encoder\PasswordEncoderInterface; use Symfony\Component\Security\Core\Encoder\UserPasswordEncoderInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; +use Symfony\Component\Routing\Annotation\Route; +use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter; /** @@ -48,63 +50,38 @@ class UserController extends CRUDController * @param ValidatorInterface $validator */ public function __construct( - LoggerInterface $logger, + LoggerInterface $chillLogger, ValidatorInterface $validator, UserPasswordEncoderInterface $passwordEncoder ) { - $this->logger = $logger; + $this->logger = $chillLogger; $this->validator = $validator; $this->passwordEncoder = $passwordEncoder; } - /** - * Creates a new User entity. - * - */ - public function new(Request $request): Response + protected function createFormFor(string $action, $entity, string $formClass = null, array $formOptions = []): FormInterface { - $user = new User(); - $form = $this->createCreateForm($user); - $form->handleRequest($request); - - if ($form->isSubmitted() && $form->isValid()) { - $em = $this->getDoctrine()->getManager(); - - $user->setPassword($this->passwordEncoder - ->encodePassword($user, $form['plainPassword']->getData())); - - $em->persist($user); - $em->flush(); - - return $this->redirect($this->generateUrl('admin_user_show', array('id' => $user->getId()))); - } elseif ($form->isSubmitted() && !$form->isValid()){ - + // for "new", add special config + if ('new' === $action) { + return $this->createForm(UserType::class, $entity, array( + 'is_creation' => true + )); } - return $this->render('@ChillMain/User/new.html.twig', array( - 'entity' => $user, - 'form' => $form->createView(), - )); + // default behaviour + return parent::createFormFor($action, $entity, $formClass, $formOptions); } - /** - * Creates a form to create a User entity. - * - * @param User $entity The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createCreateForm(User $entity) + protected function onPrePersist(string $action, $entity, FormInterface $form, Request $request) { - $form = $this->createForm(UserType::class, $entity, array( - 'action' => $this->generateUrl('admin_user_create'), - 'method' => 'POST', - 'is_creation' => true - )); + // for "new", encode the password + if ('new' === $action) { + $entity->setPassword($this->passwordEncoder + ->encodePassword($entity, $form['plainPassword']->getData())); + } - $form->add('submit', SubmitType::class, array('label' => 'Create')); - - return $form; + // default behaviour + parent::onPrePersist($action, $entity, $form, $request); } /** @@ -126,55 +103,63 @@ class UserController extends CRUDController )); } - /** - * Displays a form to edit an existing User entity. - * - */ - public function editAction($id) + + protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []) { - $em = $this->getDoctrine()->getManager(); - - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); + // add mini-forms for edit action + if ("edit" === $action) { + return array_merge( + $defaultTemplateParameters, + [ + 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($entity, $request)->createView(), + 'delete_groupcenter_form' => array_map( + function(\Symfony\Component\Form\Form $form) { + return $form->createView(); + }, + iterator_to_array($this->getDeleteLinkGroupCenterByUser($entity, $request), true) + ) + ] + ); } - $editForm = $this->createEditForm($user); - - return $this->render('@ChillMain/User/edit.html.twig', array( - 'entity' => $user, - 'edit_form' => $editForm->createView(), - 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), - 'delete_groupcenter_form' => array_map( - function(\Symfony\Component\Form\Form $form) { - return $form->createView(); - - }, - iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) - )); + // default behaviour + return parent::generateTemplateParameter($action, $entity, $request, $defaultTemplateParameters); } /** * Displays a form to edit the user password. * + * @Route("/{_locale}/admin/user/{id}/edit_password", name="admin_user_edit_password") */ - public function editPasswordAction($id) + public function editPasswordAction(User $user, Request $request) { - $em = $this->getDoctrine()->getManager(); + $editForm = $this->createEditPasswordForm($user, $request); + $editForm->handleRequest($request); - $user = $em->getRepository('ChillMainBundle:User')->find($id); + if ($editForm->isSubmitted() && $editForm->isValid()) { + $password = $editForm->get('new_password')->getData(); - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); + // logging for prod + $this->logger->info('update password for an user', [ + 'by' => $this->getUser()->getUsername(), + 'user' => $user->getUsername() + ]); + + $user->setPassword($this->passwordEncoder->encodePassword($user, $password)); + + $this->getDoctrine()->getManager()->flush(); + $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!')); + + return $this->redirect( + $request->query->has('returnPath') ? $request->query->get('returnPath') : + $this->generateUrl('chill_crud_admin_user_edit', ['id' => $user->getId()]) + ); } - $editForm = $this->createEditPasswordForm($user); - - return $this->render('@ChillMain/User/edit_password.html.twig', array( + return $this->render('@ChillMain/User/edit_password.html.twig', [ 'entity' => $user, 'edit_form' => $editForm->createView() - )); + ]); } /** @@ -186,9 +171,6 @@ class UserController extends CRUDController private function createEditPasswordForm(User $user) { return $this->createForm(UserPasswordType::class, null, array( - 'action' => - $this->generateUrl('admin_user_update_password', array('id' => $user->getId())), - 'method' => 'PUT', 'user' => $user )) ->add('submit', SubmitType::class, array('label' => 'Change password')) @@ -196,7 +178,11 @@ class UserController extends CRUDController ; } - public function deleteLinkGroupCenterAction($uid, $gcid) + /** + * @Route("/{_locale}/admin/main/user/{uid}/delete_link_groupcenter/{gcid}", + * name="admin_user_delete_groupcenter") + */ + public function deleteLinkGroupCenterAction($uid, $gcid, Request $request): RedirectResponse { $em = $this->getDoctrine()->getManager(); @@ -218,7 +204,7 @@ class UserController extends CRUDController } catch (\RuntimeException $ex) { $this->addFlash('error', $this->get('translator')->trans($ex->getMessage())); - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid))); + return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', array('id' => $uid))); } $em->flush(); @@ -226,11 +212,15 @@ class UserController extends CRUDController $this->addFlash('success', $this->get('translator') ->trans('The permissions where removed.')); - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $uid))); + return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', array('id' => $uid))); } - public function addLinkGroupCenterAction(Request $request, $uid) + /** + * @Route("/{_locale}/admin/main/user/{uid}/add_link_groupcenter", + * name="admin_user_add_groupcenter") + */ + public function addLinkGroupCenterAction(Request $request, $uid): RedirectResponse { $em = $this->getDoctrine()->getManager(); @@ -240,7 +230,7 @@ class UserController extends CRUDController throw $this->createNotFoundException('Unable to find User entity.'); } - $form = $this->createAddLinkGroupCenterForm($user); + $form = $this->createAddLinkGroupCenterForm($user, $request); $form->handleRequest($request); if ($form->isValid()) { @@ -254,8 +244,12 @@ class UserController extends CRUDController $this->addFlash('success', $this->get('translator')->trans('The ' . 'permissions have been successfully added to the user')); - return $this->redirect($this->generateUrl('admin_user_edit', - array('id' => $uid))); + $returnPathParams = $request->query->has('returnPath') ? + ['returnPath' => $request->query->get('returnPath')] : []; + + return $this->redirect($this->generateUrl('chill_crud_admin_user_edit', + \array_merge(['id' => $uid], $returnPathParams))); + } else { foreach($this->validator->validate($user) as $error) $this->addFlash('error', $error->getMessage()); @@ -293,104 +287,6 @@ class UserController extends CRUDController return $groupCenterManaged; } - /** - * Creates a form to edit a User entity. - * - * @param User $user The entity - * - * @return \Symfony\Component\Form\Form The form - */ - private function createEditForm(User $user) - { - $form = $this->createForm(UserType::class, $user, array( - 'action' => $this->generateUrl('admin_user_update', array('id' => $user->getId())), - 'method' => 'PUT', - )); - - $form->add('submit', SubmitType::class, array('label' => 'Update')); - - return $form; - } - - /** - * Edits an existing User entity. - * - */ - public function updateAction(Request $request, $id) - { - $em = $this->getDoctrine()->getManager(); - - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); - } - - $editForm = $this->createEditForm($user); - $editForm->handleRequest($request); - - if ($editForm->isValid()) { - $em->flush(); - - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); - } - - return $this->render('@ChillMain/User/edit.html.twig', array( - 'entity' => $user, - 'edit_form' => $editForm->createView(), - 'add_groupcenter_form' => $this->createAddLinkGroupCenterForm($user)->createView(), - 'delete_groupcenter_form' => array_map( - function(\Symfony\Component\Form\Form $form) { - return $form->createView(); - - }, - iterator_to_array($this->getDeleteLinkGroupCenterByUser($user), true)) - )); - } - - /** - * Edits the user password - * - */ - public function updatePasswordAction(Request $request, $id) - { - $em = $this->getDoctrine()->getManager(); - - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); - } - - $editForm = $this->createEditPasswordForm($user); - $editForm->handleRequest($request); - - if ($editForm->isValid()) { - $password = $editForm->get('new_password')->getData(); - - // logging for prod - $this->logger->info('update password for an user', [ - 'by' => $this->getUser()->getUsername(), - 'user' => $user->getUsername() - ]); - - $user->setPassword($this->get('security.password_encoder') - ->encodePassword($user, $password)); - - $em->flush(); - - $this->addFlash('success', $this->get('translator')->trans('Password successfully updated!')); - - return $this->redirect($this->generateUrl('admin_user_edit', array('id' => $id))); - } - - return $this->render('@ChillMain/User/edit_password.html.twig', array( - 'entity' => $user, - 'edit_form' => $editForm->createView(), - )); - } - - /** * Creates a form to delete a link to a GroupCenter * @@ -398,11 +294,13 @@ class UserController extends CRUDController * * @return \Symfony\Component\Form\Form The form */ - private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter) + private function createDeleteLinkGroupCenterForm(User $user, GroupCenter $groupCenter, $request) { + $returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : []; + return $this->createFormBuilder() - ->setAction($this->generateUrl('admin_user_delete_group_center', - array('uid' => $user->getId(), 'gcid' => $groupCenter->getId()))) + ->setAction($this->generateUrl('admin_user_delete_groupcenter', + array_merge($returnPathParams, ['uid' => $user->getId(), 'gcid' => $groupCenter->getId()]))) ->setMethod('DELETE') ->add('submit', SubmitType::class, array('label' => 'Delete')) ->getForm() @@ -415,11 +313,13 @@ class UserController extends CRUDController * @param User $user * @return \Symfony\Component\Form\Form */ - private function createAddLinkGroupCenterForm(User $user) + private function createAddLinkGroupCenterForm(User $user, Request $request) { + $returnPathParams = $request->query->has('returnPath') ? ['returnPath' => $request->query->get('returnPath')] : []; + return $this->createFormBuilder() - ->setAction($this->generateUrl('admin_user_add_group_center', - array('uid' => $user->getId()))) + ->setAction($this->generateUrl('admin_user_add_groupcenter', + array_merge($returnPathParams, ['uid' => $user->getId()]))) ->setMethod('POST') ->add(self::FORM_GROUP_CENTER_COMPOSED, ComposedGroupCenterType::class) ->add('submit', SubmitType::class, array('label' => 'Add a new groupCenter')) @@ -431,11 +331,11 @@ class UserController extends CRUDController * * @param User $user */ - private function getDeleteLinkGroupCenterByUser(User $user) + private function getDeleteLinkGroupCenterByUser(User $user, Request $request) { foreach ($user->getGroupCenters() as $groupCenter) { yield $groupCenter->getId() => $this - ->createDeleteLinkGroupCenterForm($user, $groupCenter); + ->createDeleteLinkGroupCenterForm($user, $groupCenter, $request); } } } diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 65b8ffdf6..e8c43e02d 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -307,9 +307,11 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, ], 'new' => [ 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/User/new.html.twig' ], 'edit' => [ 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/User/edit.html.twig' ] ] ] diff --git a/src/Bundle/ChillMainBundle/Form/UserType.php b/src/Bundle/ChillMainBundle/Form/UserType.php index 09e2d1391..bf056cec5 100644 --- a/src/Bundle/ChillMainBundle/Form/UserType.php +++ b/src/Bundle/ChillMainBundle/Form/UserType.php @@ -47,9 +47,9 @@ class UserType extends AbstractType ]) ->add('label', TextType::class) ->add('mainCenter', EntityType::class, [ - 'label' => 'main center', + 'label' => 'Main center', 'required' => false, - 'placeholder' => 'choose a main center', + 'placeholder' => 'Choose a main center', 'class' => Center::class, 'query_builder' => function (EntityRepository $er) { $qb = $er->createQueryBuilder('c'); @@ -59,16 +59,16 @@ class UserType extends AbstractType } ]) ->add('mainScope', EntityType::class, [ - 'label' => 'Choose a main scope', + 'label' => 'Main scope', 'required' => false, - 'placeholder' => 'choose a main scope', + 'placeholder' => 'Choose a main scope', 'class' => Scope::class, 'choice_label' => function (Scope $c) { return $this->translatableStringHelper->localize($c->getName()); }, ]) ->add('userJob', EntityType::class, [ - 'label' => 'Choose a job', + 'label' => 'user job', 'required' => false, 'placeholder' => 'choose a job', 'class' => UserJob::class, diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig index cc2673960..5e338d5fd 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_edit_content.html.twig @@ -1,17 +1,22 @@ +{% set formId = crudMainFormId|default('crud_main_form') %}
    {% block crud_content_header %}

    {{ ('crud.'~crud_name~'.title_edit')|trans }}

    {% endblock crud_content_header %} {% block crud_content_form %} - {{ form_start(form) }} - + {{ form_start(form, { 'attr' : { 'id': formId } } ) }} + {% block crud_content_form_rows %} {% for f in form %} {{ form_row(f) }} {% endfor %} {% endblock crud_content_form_rows %} + {{ form_end(form) }} + + {% block crud_content_after_form %}{% endblock %} + {% block crud_content_form_actions %}
      {% block content_form_actions_back %} @@ -30,7 +35,7 @@ {% endif %} {% endif %} - {% endblock content_form_actions_delete %} + {% endblock content_form_actions_delete %} {% block content_form_actions_view %} {% if chill_crud_action_exists(crud_name, 'view') %} {% if is_granted(chill_crud_config('role', crud_name, 'view'), entity) %} @@ -39,17 +44,17 @@ {% endif %} {% endif %} - {% endblock content_form_actions_view %} + {% endblock content_form_actions_view %} {% block content_form_actions_save_and_close %}
    • -
    • {% endblock %} {% block content_form_actions_save_and_show %}
    • -
    • @@ -58,6 +63,5 @@
    {% endblock %} - {{ form_end(form) }} {% endblock %}
    diff --git a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig index ff5fe7263..4c2003617 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/CRUD/_new_content.html.twig @@ -5,14 +5,16 @@ {% block crud_content_form %} {{ form_start(form) }} - + {% block crud_content_form_rows %} {% for f in form %}{% if f.vars.name != 'submit' %} {{ form_row(f) }} {% endif %}{% endfor %} {% endblock crud_content_form_rows %} - {% block crud_content_form_actions %} + {% block crud_content_after_form %}{% endblock %} + + {% block crud_content_form_actions %}
      {% block content_form_actions_back %}
    • @@ -20,7 +22,7 @@ {{ 'Cancel'|trans }}
    • - {% endblock %} + {% endblock %} {% block content_form_actions_save_and_close %}
    - - - - - - - - - {% for groupcenter in entity.groupcenters %} - - + + + {% endfor %} + +
    {{ 'Permission group'|trans }}{{ 'Center'|trans }} 
    + {% if entity.groupcenters|length > 0 %} + + + + + + + + + + {% for groupcenter in entity.groupcenters %} + + - + - - - {% endfor %} - -
    {{ 'Permission group'|trans }}{{ 'Center'|trans }} 
    {{ groupcenter.permissionsgroup.name }} - + {{ groupcenter.center.name }} - - {{ form_start(delete_groupcenter_form[groupcenter.id]) }} - {{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }} - {{ form_rest(delete_groupcenter_form[groupcenter.id]) }} - {{ form_end(delete_groupcenter_form[groupcenter.id]) }} -
    - {% else %} -

    {{ 'Any permissions granted to this user'|trans }}.

    - {% endif %} - -

    {{ 'Grant new permissions'|trans }}

    - - {{ form_start(add_groupcenter_form) }} - {{ form_row(add_groupcenter_form.composed_groupcenter.center) }} - {{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }} - {{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }} +
    + {{ form_start(delete_groupcenter_form[groupcenter.id]) }} + {{ form_row(delete_groupcenter_form[groupcenter.id].submit, { 'attr': { 'class': 'btn btn-chill-red' } } ) }} + {{ form_rest(delete_groupcenter_form[groupcenter.id]) }} + {{ form_end(delete_groupcenter_form[groupcenter.id]) }} +
    + {% else %} +

    {{ 'Any permissions granted to this user'|trans }}.

    + {% endif %} - {{ form_end(add_groupcenter_form) }} - - +

    {{ 'Grant new permissions'|trans }}

    + + {{ form_start(add_groupcenter_form) }} + {{ form_row(add_groupcenter_form.composed_groupcenter.center) }} + {{ form_row(add_groupcenter_form.composed_groupcenter.permissionsgroup) }} + {{ form_row(add_groupcenter_form.submit, { 'attr' : { 'class': 'btn btn-chill-green' } } ) }} + + {{ form_end(add_groupcenter_form) }} + + {% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig index 3280b3679..c26f6cf24 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/edit_password.html.twig @@ -1,4 +1,4 @@ -{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} +{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block title %}{{ 'Edit password for %username%'|trans( { '%username%': entity.username } ) }}{% endblock %} @@ -7,19 +7,17 @@ {{ form_start(edit_form) }} {{ form_row(edit_form.new_password) }} - {{ form_widget(edit_form.submit, { 'attr': { 'class': 'btn btn-chill-orange' } } ) }} + + + {{ form_end(edit_form) }} - - {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index be8a02d87..1f96cf4cb 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -41,14 +41,14 @@ @@ -59,54 +59,3 @@ {% endblock %} {% endembed %} {% endblock %} - -{# - - - - - - - - - - {% for entity in entities %} - - - - - {% endfor %} - -
    {{ 'Username'|trans|capitalize }}{{ 'Actions'|trans|capitalize }}
    {{ entity.username }} - -
    - - - -{% endblock admin_content %} - -#} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig index b2234ef30..f0757b25d 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/new.html.twig @@ -1,22 +1,7 @@ -{% extends '@ChillMain/Admin/layout_permissions.html.twig' %} - -{% block title %}{{ 'User creation'|trans }}{% endblock %} +{% extends '@ChillMain/Admin/Permission/layout_crud_permission_index.html.twig' %} {% block admin_content -%} -

    {{ 'User creation'|trans }}

    - - {{ form_start(form) }} - {{ form_row(form.username) }} - {{ form_row(form.email) }} - {{ form_row(form.plainPassword) }} - {{ form_widget(form.submit, { 'attr' : { 'class': 'btn btn-chill-blue' } }) }} - {{ form_end(form) }} - - + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php index 76cae45f5..64c9f857a 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php @@ -24,10 +24,6 @@ class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilde ]); $menu->addChild('List users', [ - 'route' => 'admin_user' - ])->setExtras(['order' => 400]); - - $menu->addChild('List users CRUD', [ 'route' => 'chill_crud_admin_user_index' ])->setExtras(['order' => 400]); diff --git a/src/Bundle/ChillMainBundle/config/routes/user.yaml b/src/Bundle/ChillMainBundle/config/routes/user.yaml index de62a570e..aee1393f5 100644 --- a/src/Bundle/ChillMainBundle/config/routes/user.yaml +++ b/src/Bundle/ChillMainBundle/config/routes/user.yaml @@ -1,44 +1,44 @@ -admin_user: - path: / - controller: Chill\MainBundle\Controller\UserController::indexAction - -admin_user_show: - path: /{id}/show - controller: Chill\MainBundle\Controller\UserController::showAction - -admin_user_new: - path: /new - controller: Chill\MainBundle\Controller\UserController::newAction - -admin_user_create: - path: /create - controller: Chill\MainBundle\Controller\UserController::createAction - methods: POST - -admin_user_edit: - path: /{id}/edit - controller: Chill\MainBundle\Controller\UserController::editAction - -admin_user_edit_password: - path: /{id}/edit_password - controller: Chill\MainBundle\Controller\UserController::editPasswordAction - -admin_user_update: - path: /{id}/update - controller: Chill\MainBundle\Controller\UserController::updateAction - methods: [POST, PUT] - -admin_user_update_password: - path: /{id}/update_password - controller: Chill\MainBundle\Controller\UserController::updatePasswordAction - methods: [POST, PUT] - -admin_user_delete_group_center: - path: /{uid}/delete_link_groupcenter/{gcid} - controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction - methods: [DELETE] - -admin_user_add_group_center: - path: /{uid}/add_link_groupcenter - controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction - methods: [POST] +#admin_user: +# path: / +# controller: Chill\MainBundle\Controller\UserController::indexAction +# +#admin_user_show: +# path: /{id}/show +# controller: Chill\MainBundle\Controller\UserController::showAction +# +#admin_user_new: +# path: /new +# controller: Chill\MainBundle\Controller\UserController::newAction +# +#admin_user_create: +# path: /create +# controller: Chill\MainBundle\Controller\UserController::createAction +# methods: POST +# +#admin_user_edit: +# path: /{id}/edit +# controller: Chill\MainBundle\Controller\UserController::editAction +# +#admin_user_edit_password: +# path: /{id}/edit_password +# controller: Chill\MainBundle\Controller\UserController::editPasswordAction +# +#admin_user_update: +# path: /{id}/update +# controller: Chill\MainBundle\Controller\UserController::updateAction +# methods: [POST, PUT] +# +#admin_user_update_password: +# path: /{id}/update_password +# controller: Chill\MainBundle\Controller\UserController::updatePasswordAction +# methods: [POST, PUT] +# +#admin_user_delete_group_center: +# path: /{uid}/delete_link_groupcenter/{gcid} +# controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction +# methods: [DELETE] +# +#admin_user_add_group_center: +# path: /{uid}/add_link_groupcenter +# controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction +# methods: [POST] From 430177f0c754f0f4d691959090ec6988bf5cc178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 23 Sep 2021 14:09:51 +0200 Subject: [PATCH 16/27] some finalisation for admin user --- .../Controller/UserController.php | 20 ++------- .../ChillMainExtension.php | 2 +- .../Resources/views/User/edit.html.twig | 1 + .../Resources/views/User/index.html.twig | 5 +-- .../MenuBuilder/PermissionMenuBuilder.php | 2 +- src/Bundle/ChillMainBundle/config/routes.yaml | 4 -- .../ChillMainBundle/config/routes/user.yaml | 44 ------------------- .../translations/messages.fr.yml | 12 ++++- 8 files changed, 19 insertions(+), 71 deletions(-) delete mode 100644 src/Bundle/ChillMainBundle/config/routes/user.yaml diff --git a/src/Bundle/ChillMainBundle/Controller/UserController.php b/src/Bundle/ChillMainBundle/Controller/UserController.php index 99de70747..735546eba 100644 --- a/src/Bundle/ChillMainBundle/Controller/UserController.php +++ b/src/Bundle/ChillMainBundle/Controller/UserController.php @@ -4,6 +4,7 @@ namespace Chill\MainBundle\Controller; use Chill\MainBundle\CRUD\Controller\AbstractCRUDController; use Chill\MainBundle\CRUD\Controller\CRUDController; +use Chill\MainBundle\Pagination\PaginatorInterface; use Doctrine\ORM\EntityManagerInterface; use Psr\Log\LoggerInterface; use Symfony\Component\Form\FormInterface; @@ -84,26 +85,13 @@ class UserController extends CRUDController parent::onPrePersist($action, $entity, $form, $request); } - /** - * Finds and displays a User entity. - * - */ - public function showAction($id) + protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator) { - $em = $this->getDoctrine()->getManager(); + $query->addOrderBy('e.usernameCanonical', 'ASC'); - $user = $em->getRepository('ChillMainBundle:User')->find($id); - - if (!$user) { - throw $this->createNotFoundException('Unable to find User entity.'); - } - - return $this->render('@ChillMain/User/show.html.twig', array( - 'entity' => $user, - )); + return parent::orderQuery($action, $query, $request, $paginator); } - protected function generateTemplateParameter(string $action, $entity, Request $request, array $defaultTemplateParameters = []) { // add mini-forms for edit action diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index e8c43e02d..f196b8a2b 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -297,7 +297,7 @@ class ChillMainExtension extends Extension implements PrependExtensionInterface, 'class' => User::class, 'controller' => UserController::class, 'name' => 'admin_user', - 'base_path' => '/admin/main/user2', + 'base_path' => '/admin/main/user', 'base_role' => 'ROLE_ADMIN', 'form_class' => UserType::class, 'actions' => [ diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig index 38889cf72..0ea1d529c 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/edit.html.twig @@ -51,5 +51,6 @@ {{ form_end(add_groupcenter_form) }} {% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} {% endembed %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig index 1f96cf4cb..c57d9ed5f 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/User/index.html.twig @@ -2,7 +2,7 @@ {% block admin_content -%} {% embed '@ChillMain/CRUD/_index.html.twig' %} - {% block table_entites_thead_tr %} + {% block table_entities_thead_tr %} {{ 'crud.admin_user.index.is_active'|trans }} {{ 'crud.admin_user.index.usernames'|trans }} {{ 'crud.admin_user.index.mains'|trans }} @@ -44,7 +44,7 @@
  • - +
  • {% if is_granted('ROLE_ALLOWED_TO_SWITCH') %}
  • @@ -53,7 +53,6 @@ {% endif %}
- {% endfor %} {% endblock %} diff --git a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php index 64c9f857a..470930820 100644 --- a/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php +++ b/src/Bundle/ChillMainBundle/Routing/MenuBuilder/PermissionMenuBuilder.php @@ -23,7 +23,7 @@ class PermissionMenuBuilder implements \Chill\MainBundle\Routing\LocalMenuBuilde 'order' => 300 ]); - $menu->addChild('List users', [ + $menu->addChild('crud.admin_user.index.title', [ 'route' => 'chill_crud_admin_user_index' ])->setExtras(['order' => 400]); diff --git a/src/Bundle/ChillMainBundle/config/routes.yaml b/src/Bundle/ChillMainBundle/config/routes.yaml index d75e91363..9a155f6e6 100644 --- a/src/Bundle/ChillMainBundle/config/routes.yaml +++ b/src/Bundle/ChillMainBundle/config/routes.yaml @@ -6,10 +6,6 @@ chill_main_admin_permissionsgroup: resource: "@ChillMainBundle/config/routes/permissionsgroup.yaml" prefix: "{_locale}/admin/permissionsgroup" -chill_main_admin_user: - resource: "@ChillMainBundle/config/routes/user.yaml" - prefix: "{_locale}/admin/user" - chill_main_admin_scope: resource: "@ChillMainBundle/config/routes/scope.yaml" prefix: "{_locale}/admin/scope" diff --git a/src/Bundle/ChillMainBundle/config/routes/user.yaml b/src/Bundle/ChillMainBundle/config/routes/user.yaml deleted file mode 100644 index aee1393f5..000000000 --- a/src/Bundle/ChillMainBundle/config/routes/user.yaml +++ /dev/null @@ -1,44 +0,0 @@ -#admin_user: -# path: / -# controller: Chill\MainBundle\Controller\UserController::indexAction -# -#admin_user_show: -# path: /{id}/show -# controller: Chill\MainBundle\Controller\UserController::showAction -# -#admin_user_new: -# path: /new -# controller: Chill\MainBundle\Controller\UserController::newAction -# -#admin_user_create: -# path: /create -# controller: Chill\MainBundle\Controller\UserController::createAction -# methods: POST -# -#admin_user_edit: -# path: /{id}/edit -# controller: Chill\MainBundle\Controller\UserController::editAction -# -#admin_user_edit_password: -# path: /{id}/edit_password -# controller: Chill\MainBundle\Controller\UserController::editPasswordAction -# -#admin_user_update: -# path: /{id}/update -# controller: Chill\MainBundle\Controller\UserController::updateAction -# methods: [POST, PUT] -# -#admin_user_update_password: -# path: /{id}/update_password -# controller: Chill\MainBundle\Controller\UserController::updatePasswordAction -# methods: [POST, PUT] -# -#admin_user_delete_group_center: -# path: /{uid}/delete_link_groupcenter/{gcid} -# controller: Chill\MainBundle\Controller\UserController::deleteLinkGroupCenterAction -# methods: [DELETE] -# -#admin_user_add_group_center: -# path: /{uid}/add_link_groupcenter -# controller: Chill\MainBundle\Controller\UserController::addLinkGroupCenterAction -# methods: [POST] diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index f799f20b6..d99a565c1 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -143,10 +143,8 @@ The role '%role%' has been removed: Le rôle "%role%" a été enlevé de ce grou The role '%role%' on circle '%scope%' has been removed: Le rôle "%role%" sur le cercle "%scope%" a été enlevé de ce groupe de permission #admin section for users -List users: Liste des utilisateurs user list: Liste des utilisateurs User edit: Modification d'un utilisateur -User creation: Créer un utilisateur User'status: Statut de l'utilisateur Disabled, the user is not allowed to login: Désactivé, l'utilisateur n'est pas autorisé à se connecter Enabled, the user is active: Actif, l'utilisateur peut se connecter @@ -281,6 +279,16 @@ crud: success: Les données ont été enregistrées view: link_duplicate: Dupliquer + ## admin for users + admin_user: + index: + title: Utilisateurs + add_new: "Créer" + is_active: "Actif ?" + usernames: "Identifiants" + mains: "Champs principaux" + title_new: "Nouvel utilisateur" + title_edit: Modifier un utilisateur No entities: Aucun élément CHILL_FOO_SEE: Voir un élément From 1d4b1d852f5404cf3d87c813163866f18db30c9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Sep 2021 10:35:28 +0200 Subject: [PATCH 17/27] improve layout for admin --- .../Repository/UserJobRepository.php | 49 +++++++++++++++++++ .../Resources/views/Admin/layout.html.twig | 25 +--------- .../Resources/views/Layout/_header.html.twig | 43 +++++----------- .../Resources/views/layout.html.twig | 22 --------- .../views/layoutWithVerticalMenu.html.twig | 23 --------- 5 files changed, 63 insertions(+), 99 deletions(-) create mode 100644 src/Bundle/ChillMainBundle/Repository/UserJobRepository.php diff --git a/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php b/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php new file mode 100644 index 000000000..f19952c31 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Repository/UserJobRepository.php @@ -0,0 +1,49 @@ +repository = $em->getRepository(UserJob::class); + } + + public function find($id): ?UserJob + { + return $this->repository->find($id); + } + + /** + * @return array|UserJob[] + */ + public function findAll(): array + { + return $this->repository->findAll(); + } + + /** + * @return array|UserJob[]|object[] + */ + public function findBy(array $criteria, ?array $orderBy = null, $limit = null, $offset = null) + { + return $this->repository->findBy($criteria, $orderBy, $limit, $offset); + } + + public function findOneBy(array $criteria) + { + return $this->repository->findOneBy($criteria); + } + + public function getClassName() + { + return UserJob::class; + } +} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig index c3331b08b..6efca3256 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Admin/layout.html.twig @@ -1,26 +1,3 @@ -{# - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, - / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} - -{# - The layout of the admin section. All the page / template of the admin section must use this - layout. -#} - {% extends "@ChillMain/layout.html.twig" %} {% block navigation_search_bar %}{% endblock %} @@ -38,4 +15,4 @@ {% endblock %} -{% endblock %} \ No newline at end of file +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig index 605be2da6..ab823ff2e 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Layout/_header.html.twig @@ -1,20 +1,3 @@ -{# - * Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, - * / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#}
diff --git a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig index dc500642c..27fc4430b 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layout.html.twig @@ -1,25 +1,3 @@ -{# - * Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, - / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see . -#} - -{# - The basic layout of Chill. All the page / template of Chill must use this template. -#} - diff --git a/src/Bundle/ChillMainBundle/Resources/views/layoutWithVerticalMenu.html.twig b/src/Bundle/ChillMainBundle/Resources/views/layoutWithVerticalMenu.html.twig index be582ab3b..c192eaaac 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/layoutWithVerticalMenu.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/layoutWithVerticalMenu.html.twig @@ -1,26 +1,3 @@ -{# - * Copyright (C) 2014-2021, Champs Libres Cooperative SCRLFS, - / - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . -#} - -{# - Layout with a vertical menu and a conainer for the content (like admin, export) - ( for the vertical menu you can extends Menu/veticalMenu.html.twig ). -#} - {% extends "@ChillMain/layout.html.twig" %} {% block sublayout_content %} From 62f8d2c01d73351cf6b7c245bafb318186db120e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Sep 2021 13:51:43 +0200 Subject: [PATCH 18/27] fixes quick for accompanying cours edocument voter --- .../AccompanyingCourseDocumentVoter.php | 20 +++++++------------ .../Resources/views/Menu/user.html.twig | 6 +++--- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php index 8354e63e7..944a27b27 100644 --- a/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php +++ b/src/Bundle/ChillDocStoreBundle/Security/Authorization/AccompanyingCourseDocumentVoter.php @@ -7,6 +7,7 @@ use Chill\MainBundle\Security\Authorization\AbstractChillVoter; use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\ProvideRoleHierarchyInterface; use Chill\MainBundle\Entity\User; +use Symfony\Component\Security\Core\Authentication\Token\TokenInterface; use Symfony\Component\Security\Core\Authorization\AccessDecisionManagerInterface; use Psr\Log\LoggerInterface; @@ -57,30 +58,23 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov self::DELETE ]; } - + protected function supports($attribute, $subject) { - if (\in_array($attribute, $this->getRoles()) && $subject instanceof AccompanyingCourseDocument) { + + if (\in_array($attribute, $this->getRoles())) { return true; } - - //if ($subject instanceof AccompanyingPeriod && $attribute === self::CREATE) { - return true; - //} - + return false; } - protected function isGranted($attribute, $report, $user = null) + protected function voteOnAttribute($attribute, $subject, TokenInterface $token) { - if (! $user instanceof User){ - return false; - } - // TODO - // return $this->helper->userHasAccess($user, $report, $attribute); return true; } + public function getRolesWithoutScope() { return array(); diff --git a/src/Bundle/ChillMainBundle/Resources/views/Menu/user.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Menu/user.html.twig index c083bcb19..e42faeeb6 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Menu/user.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Menu/user.html.twig @@ -25,7 +25,7 @@ aria-expanded="false"> {{ 'Welcome' | trans }}
- + {{ app.user.username }} {{ render(controller('ChillMainBundle:UI:showNotificationUserCounter')) }} @@ -40,8 +40,8 @@ {% for menu in menus %} {% if is_granted('ROLE_PREVIOUS_ADMIN') and menu.name == 'Logout' %} -
+ {{ 'Exit impersonation'|trans }} {% else %} Date: Fri, 24 Sep 2021 16:04:32 +0200 Subject: [PATCH 19/27] attempt to fix migrations --- .../migrations/Version20210903091534.php | 2 +- .../migrations/Version20210903123835.php | 168 ------------- .../migrations/Version20210924134934.php | 221 ++++++++++++++++++ 3 files changed, 222 insertions(+), 169 deletions(-) create mode 100644 src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php index b19c07f09..bb9e453e7 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.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; diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php index ae8c4bd17..b7d8f78db 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php @@ -19,13 +19,6 @@ final class Version20210903123835 extends AbstractMigration public function up(Schema $schema): void { - // this up() migration is auto-generated, please modify it to your needs - // $this->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'); @@ -42,171 +35,10 @@ final class Version20210903123835 extends AbstractMigration $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'); diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php new file mode 100644 index 000000000..85092ac1c --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php @@ -0,0 +1,221 @@ +addSql('DROP SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq CASCADE'); + $this->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, category_bundle_id VARCHAR(255) DEFAULT NULL, category_id_inside_bundle INT DEFAULT NULL, object_id INT DEFAULT NULL, scope_id INT DEFAULT NULL, user_id INT DEFAULT NULL, course_id INT NOT NULL, title TEXT NOT NULL, description TEXT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); + $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('CREATE INDEX IDX_A45098F6591CC992 ON chill_doc.accompanyingcourse_document (course_id)'); + $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('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('DROP TABLE chill_main_address_legacy'); + // $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP CONSTRAINT fk_7bf90dbe727aca70'); + // $this->addSql('DROP INDEX idx_7bf90dbe727aca70'); + // $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP parent_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 activitytype ALTER category_id DROP DEFAULT'); + // $this->addSql('DROP INDEX internal_center_geom_idx'); + // $this->addSql('ALTER TABLE chill_docgen_template ALTER entities SET NOT NULL'); + // $this->addSql('ALTER TABLE chill_docgen_template ALTER context SET NOT NULL'); + // $this->addSql('DROP INDEX chill_custom_main_address_filtering_idx'); + // $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_household DROP CONSTRAINT fk_household_comment_embeddable_user'); + // $this->addSql('DROP INDEX IDX_BE50A270116F5FA9'); + // $this->addSql('DROP INDEX chill_custom_person_household_members_sharing_idx'); + // $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 phonenumber_trgm_idx'); + // $this->addSql('DROP INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin'); + // $this->addSql('DROP INDEX mobilenumber_trgm_idx'); + // $this->addSql('DROP INDEX fullnamecanonical_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_vendee.security_profile_jobs ADD CONSTRAINT FK_AEA12596BE04EA9 FOREIGN KEY (job_id) REFERENCES chill_vendee.security_profile (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs ADD CONSTRAINT FK_AEA12596CCFA12B8 FOREIGN KEY (profile_id) REFERENCES chill_main_user_job (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('ALTER INDEX chill_vendee.uniq_idx_aea12596be04ea9 RENAME TO UNIQ_AEA12596BE04EA9'); + // $this->addSql('ALTER INDEX chill_vendee.aea12596ccfa12b8 RENAME TO IDX_AEA12596CCFA12B8'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER profile_id DROP NOT NULL'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action SET NOT NULL'); + // $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('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('DROP SEQUENCE chill_doc.accompanyingcourse_document_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_doc.accompanyingcourse_document'); + // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage DROP CONSTRAINT FK_4D319FFEF57537C3'); + // $this->addSql('ALTER INDEX chill_vendee.idx_dd0a4c00eef79338 RENAME TO idx_1a4b602deef79338'); + // $this->addSql('ALTER INDEX idx_ac74095aa76ed395 RENAME TO idx_55026b0ca76ed395'); + // $this->addSql('ALTER INDEX idx_ac74095ac54c8c93 RENAME TO idx_55026b0cc54c8c93'); + // $this->addSql('ALTER INDEX idx_ac74095a682b5931 RENAME TO idx_55026b0c682b5931'); + // $this->addSql('ALTER INDEX idx_ac74095a217bbb47 RENAME TO idx_55026b0c217bbb47'); + // $this->addSql('ALTER INDEX idx_ac74095ad7fa8ef0 RENAME TO IDX_AC74095A550B0C53'); + // $this->addSql('CREATE UNIQUE INDEX uniq_93f763ae217bbb47 ON chill_vendee.vendee_person (person_id)'); + // $this->addSql('ALTER TABLE chill_asideactivity.AsideActivityCategory ADD parent_id INT DEFAULT NULL'); + // $this->addSql('ALTER TABLE chill_asideactivity.AsideActivityCategory ADD CONSTRAINT fk_7bf90dbe727aca70 FOREIGN KEY (parent_id) REFERENCES chill_asideactivity.asideactivitycategory (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); + // $this->addSql('CREATE INDEX idx_7bf90dbe727aca70 ON chill_asideactivity.AsideActivityCategory (parent_id)'); + // $this->addSql('CREATE INDEX internal_center_geom_idx ON chill_vendee.center_polygon (geom)'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs DROP CONSTRAINT FK_AEA12596BE04EA9'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs DROP CONSTRAINT FK_AEA12596CCFA12B8'); + // $this->addSql('ALTER INDEX chill_vendee.uniq_aea12596be04ea9 RENAME TO uniq_idx_aea12596be04ea9'); + // $this->addSql('ALTER INDEX chill_vendee.idx_aea12596ccfa12b8 RENAME TO aea12596ccfa12b8'); + // $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('DROP INDEX search_name_code'); + // $this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL'); + // $this->addSql('COMMENT ON COLUMN activityreasoncategory.name IS 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('CREATE INDEX chill_custom_main_address_filtering_idx ON chill_main_address (id, validfrom, validto)'); + // $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 chill_docgen_template ALTER entities DROP NOT NULL'); + // $this->addSql('ALTER TABLE chill_docgen_template ALTER context DROP NOT NULL'); + // $this->addSql('ALTER TABLE activitytype ALTER category_id SET DEFAULT 1'); + // $this->addSql('ALTER INDEX idx_e260a868504cb38d RENAME TO idx_64a4a621504cb38d'); + // $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_accompanying_period_participation ALTER startDate SET DEFAULT \'1970-01-01\''); + // $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 chill_custom_person_household_members_sharing_idx ON chill_person_household_members (person_id, startdate, enddate, household_id) WHERE (sharedhousehold IS TRUE)'); + // $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_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 phonenumber_trgm_idx ON chill_person_person (phonenumber)'); + // $this->addSql('CREATE INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin ON chill_person_person (fullnamecanonical)'); + // $this->addSql('CREATE INDEX mobilenumber_trgm_idx ON chill_person_person (mobilenumber)'); + // $this->addSql('CREATE INDEX fullnamecanonical_trgm_idx ON chill_person_person (center_id, fullnamecanonical)'); + // $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_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 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.security_profile_action ALTER profile_id SET NOT NULL'); + // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action DROP NOT NULL'); + // $this->addSql('ALTER INDEX idx_7a48df7f5df53b66 RENAME TO idx_286dc95df53b66'); + } +} From 832c7bab9f16e9c658198bdc0f8f182d856ab591 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Fri, 24 Sep 2021 16:20:58 +0200 Subject: [PATCH 20/27] last migration deleted: duplicate --- .../migrations/Version20210924134934.php | 221 ------------------ 1 file changed, 221 deletions(-) delete mode 100644 src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php deleted file mode 100644 index 85092ac1c..000000000 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210924134934.php +++ /dev/null @@ -1,221 +0,0 @@ -addSql('DROP SEQUENCE chill_person_accompanying_period_work_eval_doc_id_seq CASCADE'); - $this->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, category_bundle_id VARCHAR(255) DEFAULT NULL, category_id_inside_bundle INT DEFAULT NULL, object_id INT DEFAULT NULL, scope_id INT DEFAULT NULL, user_id INT DEFAULT NULL, course_id INT NOT NULL, title TEXT NOT NULL, description TEXT NOT NULL, date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, PRIMARY KEY(id))'); - $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('CREATE INDEX IDX_A45098F6591CC992 ON chill_doc.accompanyingcourse_document (course_id)'); - $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('ALTER TABLE chill_doc.accompanyingcourse_document ADD CONSTRAINT FK_A45098F6591CC992 FOREIGN KEY (course_id) REFERENCES chill_person_accompanying_period (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('DROP TABLE chill_main_address_legacy'); - // $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP CONSTRAINT fk_7bf90dbe727aca70'); - // $this->addSql('DROP INDEX idx_7bf90dbe727aca70'); - // $this->addSql('ALTER TABLE chill_asideactivity.asideactivitycategory DROP parent_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 activitytype ALTER category_id DROP DEFAULT'); - // $this->addSql('DROP INDEX internal_center_geom_idx'); - // $this->addSql('ALTER TABLE chill_docgen_template ALTER entities SET NOT NULL'); - // $this->addSql('ALTER TABLE chill_docgen_template ALTER context SET NOT NULL'); - // $this->addSql('DROP INDEX chill_custom_main_address_filtering_idx'); - // $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_household DROP CONSTRAINT fk_household_comment_embeddable_user'); - // $this->addSql('DROP INDEX IDX_BE50A270116F5FA9'); - // $this->addSql('DROP INDEX chill_custom_person_household_members_sharing_idx'); - // $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 phonenumber_trgm_idx'); - // $this->addSql('DROP INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin'); - // $this->addSql('DROP INDEX mobilenumber_trgm_idx'); - // $this->addSql('DROP INDEX fullnamecanonical_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_vendee.security_profile_jobs ADD CONSTRAINT FK_AEA12596BE04EA9 FOREIGN KEY (job_id) REFERENCES chill_vendee.security_profile (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs ADD CONSTRAINT FK_AEA12596CCFA12B8 FOREIGN KEY (profile_id) REFERENCES chill_main_user_job (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('ALTER INDEX chill_vendee.uniq_idx_aea12596be04ea9 RENAME TO UNIQ_AEA12596BE04EA9'); - // $this->addSql('ALTER INDEX chill_vendee.aea12596ccfa12b8 RENAME TO IDX_AEA12596CCFA12B8'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER profile_id DROP NOT NULL'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action SET NOT NULL'); - // $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('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('DROP SEQUENCE chill_doc.accompanyingcourse_document_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_doc.accompanyingcourse_document'); - // $this->addSql('ALTER TABLE chill_vendee.vendeeperson_entourage DROP CONSTRAINT FK_4D319FFEF57537C3'); - // $this->addSql('ALTER INDEX chill_vendee.idx_dd0a4c00eef79338 RENAME TO idx_1a4b602deef79338'); - // $this->addSql('ALTER INDEX idx_ac74095aa76ed395 RENAME TO idx_55026b0ca76ed395'); - // $this->addSql('ALTER INDEX idx_ac74095ac54c8c93 RENAME TO idx_55026b0cc54c8c93'); - // $this->addSql('ALTER INDEX idx_ac74095a682b5931 RENAME TO idx_55026b0c682b5931'); - // $this->addSql('ALTER INDEX idx_ac74095a217bbb47 RENAME TO idx_55026b0c217bbb47'); - // $this->addSql('ALTER INDEX idx_ac74095ad7fa8ef0 RENAME TO IDX_AC74095A550B0C53'); - // $this->addSql('CREATE UNIQUE INDEX uniq_93f763ae217bbb47 ON chill_vendee.vendee_person (person_id)'); - // $this->addSql('ALTER TABLE chill_asideactivity.AsideActivityCategory ADD parent_id INT DEFAULT NULL'); - // $this->addSql('ALTER TABLE chill_asideactivity.AsideActivityCategory ADD CONSTRAINT fk_7bf90dbe727aca70 FOREIGN KEY (parent_id) REFERENCES chill_asideactivity.asideactivitycategory (id) NOT DEFERRABLE INITIALLY IMMEDIATE'); - // $this->addSql('CREATE INDEX idx_7bf90dbe727aca70 ON chill_asideactivity.AsideActivityCategory (parent_id)'); - // $this->addSql('CREATE INDEX internal_center_geom_idx ON chill_vendee.center_polygon (geom)'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs DROP CONSTRAINT FK_AEA12596BE04EA9'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_jobs DROP CONSTRAINT FK_AEA12596CCFA12B8'); - // $this->addSql('ALTER INDEX chill_vendee.uniq_aea12596be04ea9 RENAME TO uniq_idx_aea12596be04ea9'); - // $this->addSql('ALTER INDEX chill_vendee.idx_aea12596ccfa12b8 RENAME TO aea12596ccfa12b8'); - // $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('DROP INDEX search_name_code'); - // $this->addSql('ALTER TABLE activityreasoncategory ALTER name DROP NOT NULL'); - // $this->addSql('COMMENT ON COLUMN activityreasoncategory.name IS 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('CREATE INDEX chill_custom_main_address_filtering_idx ON chill_main_address (id, validfrom, validto)'); - // $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 chill_docgen_template ALTER entities DROP NOT NULL'); - // $this->addSql('ALTER TABLE chill_docgen_template ALTER context DROP NOT NULL'); - // $this->addSql('ALTER TABLE activitytype ALTER category_id SET DEFAULT 1'); - // $this->addSql('ALTER INDEX idx_e260a868504cb38d RENAME TO idx_64a4a621504cb38d'); - // $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_accompanying_period_participation ALTER startDate SET DEFAULT \'1970-01-01\''); - // $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 chill_custom_person_household_members_sharing_idx ON chill_person_household_members (person_id, startdate, enddate, household_id) WHERE (sharedhousehold IS TRUE)'); - // $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_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 phonenumber_trgm_idx ON chill_person_person (phonenumber)'); - // $this->addSql('CREATE INDEX chill_custom_fullnamecanonical_only_trgm_idx_gin ON chill_person_person (fullnamecanonical)'); - // $this->addSql('CREATE INDEX mobilenumber_trgm_idx ON chill_person_person (mobilenumber)'); - // $this->addSql('CREATE INDEX fullnamecanonical_trgm_idx ON chill_person_person (center_id, fullnamecanonical)'); - // $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_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 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.security_profile_action ALTER profile_id SET NOT NULL'); - // $this->addSql('ALTER TABLE chill_vendee.security_profile_action ALTER action DROP NOT NULL'); - // $this->addSql('ALTER INDEX idx_7a48df7f5df53b66 RENAME TO idx_286dc95df53b66'); - } -} From f0d0f16d3cdaad5707140be025baf325c3996c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Sep 2021 16:36:36 +0200 Subject: [PATCH 21/27] fix namespace in migration files --- .../ChillDocStoreBundle/migrations/Version20210903091534.php | 2 +- .../ChillDocStoreBundle/migrations/Version20210903123835.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php index bb9e453e7..fa4182142 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903091534.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Chill\DocStoreBundle\Migrations; +namespace Chill\Migrations\DocStore; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php index b7d8f78db..c91c7e173 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20210903123835.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Chill\DocStoreBundle\Migrations; +namespace Chill\Migrations\DocStore; use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; From d60b6aa3c4669802df76ef73342efb815b6e94d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Sep 2021 16:45:24 +0200 Subject: [PATCH 22/27] fix phpunit --- phpunit.xml.dist | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 5655e23c8..3faa756b3 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -32,7 +32,8 @@ src/Bundle/ChillPersonBundle/Tests/Controller/PersonDuplicateControllerViewTest.php - src/Bundle/ChillAsideActivityBundle/src/Tests/ + src/Bundle/ChillAsideActivityBundle/src/Tests/ + src/Bundle/ChillCalendarBundle/Tests/ From 9851efa804a7ff4f0adbc7edcd8e1217ce107eee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Sep 2021 16:54:11 +0200 Subject: [PATCH 23/27] fix deathdate not inialized --- src/Bundle/ChillPersonBundle/Entity/Person.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Entity/Person.php b/src/Bundle/ChillPersonBundle/Entity/Person.php index 2b0b5edbd..69429219f 100644 --- a/src/Bundle/ChillPersonBundle/Entity/Person.php +++ b/src/Bundle/ChillPersonBundle/Entity/Person.php @@ -146,7 +146,7 @@ class Person implements HasCenterInterface, TrackCreationInterface, TrackUpdateI * groups={"general", "creation"} * ) */ - private ?\DateTimeImmutable $deathdate; + private ?\DateTimeImmutable $deathdate = null; /** * The person's place of birth From ca7ba90717da8d9ca9eedc5d527f7528811d3715 Mon Sep 17 00:00:00 2001 From: nobohan Date: Tue, 28 Sep 2021 14:53:00 +0200 Subject: [PATCH 24/27] 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 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 25/27] 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 26/27] 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 8853359405df1eb187d754a845295135effbcd96 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 27/27] remove dump (cherry picked from commit e2230409b807eb29b820cf3cc1ac15595e5b2ff3) --- 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());