From 09aa7ff631c6358d6a37ebcc038105237bc81258 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 27 Apr 2022 17:13:38 +0200 Subject: [PATCH 1/4] change date to datetime for evaluation document --- ...companyingPeriodWorkEvaluationDocument.php | 4 +- .../migrations/Version20220427150431.php | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index cf3fb8a9f..b3feb40dd 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -40,7 +40,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null; /** - * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) + * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) * @Serializer\Groups({"read"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ @@ -111,7 +111,7 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct private ?string $title = ''; /** - * @ORM\Column(type="date_immutable", nullable=true, options={"default": null}) + * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) * @Serializer\Groups({"read"}) * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) */ diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php b/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php new file mode 100644 index 000000000..15defc95f --- /dev/null +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php @@ -0,0 +1,41 @@ +addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdat TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdat DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedat TYPE TIMESTAMP(0) WITHOUT TIME ZONE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedat DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdAt IS \'(DC2Type:datetime_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedAt IS \'(DC2Type:datetime_immutable)\''); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt TYPE DATE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt TYPE DATE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdat IS \'(DC2Type:date_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedat IS \'(DC2Type:date_immutable)\''); + } +} From daa09e2df3ed2db9f3cd63c2ea5f8aa073f8e5a7 Mon Sep 17 00:00:00 2001 From: Julie Lenaerts Date: Wed, 27 Apr 2022 17:15:04 +0200 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ea16e7fc..93cb442dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,12 +36,13 @@ and this project adheres to * [Accompanying period work evaluations] list documents associated to a work by creation date, and then by id, from the most recent to older * [Course comment] add validationConstraint NotNull and NotBlank on comment content, to avoid sql error * [Notifications] delay the sending of notificaiton to kernel.terminate -* [Notifications / Period user change] fix the sending of notification when user changes +* [Notifications / Period user change] fix the sending of notification when user changes * [Activity form] invert 'incoming' and 'receiving' in Activity form * [Activity form] keep the same order for 'attendee' field in new and edit form * [list with period] use "sameas" test operator to introduce requestor in list * [notification email on course designation] allow raw string in email content generation * [Accompanying period work] list evaluations associated to a work by startDate, and then by id, from the most recent to older +* [evaluation_document] changing date to datetime in order to display the time at which document was created (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/569) ### 2021-04-13 From fcbf62f61379616fb75eab9323cf5eb6c355e68e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 29 Apr 2022 16:41:13 +0200 Subject: [PATCH 3/4] fix cs --- .../migrations/Version20220427150431.php | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php b/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php index 15defc95f..aab3678d9 100644 --- a/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php +++ b/src/Bundle/ChillPersonBundle/migrations/Version20220427150431.php @@ -1,5 +1,12 @@ addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt TYPE DATE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt DROP DEFAULT'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt TYPE DATE'); + $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt DROP DEFAULT'); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdat IS \'(DC2Type:date_immutable)\''); + $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedat IS \'(DC2Type:date_immutable)\''); + } + public function getDescription(): string { return 'change date to datetime for evaluation documents'; @@ -27,15 +45,4 @@ final class Version20220427150431 extends AbstractMigration $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdAt IS \'(DC2Type:datetime_immutable)\''); $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedAt IS \'(DC2Type:datetime_immutable)\''); } - - public function down(Schema $schema): void - { - // this down() migration is auto-generated, please modify it to your needs - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt TYPE DATE'); - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER createdAt DROP DEFAULT'); - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt TYPE DATE'); - $this->addSql('ALTER TABLE chill_person_accompanying_period_work_evaluation_document ALTER updatedAt DROP DEFAULT'); - $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.createdat IS \'(DC2Type:date_immutable)\''); - $this->addSql('COMMENT ON COLUMN chill_person_accompanying_period_work_evaluation_document.updatedat IS \'(DC2Type:date_immutable)\''); - } } From ad96319d97f337522e463baf8e117e83cc082315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 29 Apr 2022 16:41:24 +0200 Subject: [PATCH 4/4] use traits to handle createdAt/updatedAt and by on AccompanyingCourseEvaluationDocument --- .../Doctrine/Model/TrackCreationTrait.php | 3 + .../Doctrine/Model/TrackUpdateTrait.php | 3 + ...companyingPeriodWorkEvaluationDocument.php | 96 ++----------------- 3 files changed, 12 insertions(+), 90 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php index a991399c8..cb01870bc 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackCreationTrait.php @@ -16,17 +16,20 @@ use DateTime; use DateTimeImmutable; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; trait TrackCreationTrait { /** * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) + * @Serializer\Groups({"read"}) */ private ?DateTimeImmutable $createdAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=true) + * @Serializer\Groups({"read"}) */ private ?User $createdBy = null; diff --git a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php index 3c706459c..fbe967cca 100644 --- a/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php +++ b/src/Bundle/ChillMainBundle/Doctrine/Model/TrackUpdateTrait.php @@ -16,17 +16,20 @@ use DateTime; use DateTimeImmutable; use DateTimeInterface; use Doctrine\ORM\Mapping as ORM; +use Symfony\Component\Serializer\Annotation as Serializer; trait TrackUpdateTrait { /** * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": NULL}) + * @Serializer\Groups({"read"}) */ private ?DateTimeImmutable $updatedAt = null; /** * @ORM\ManyToOne(targetEntity=User::class) * @ORM\JoinColumn(nullable=true) + * @Serializer\Groups({"read"}) */ private ?User $updatedBy = null; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php index b3feb40dd..5e412a82c 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluationDocument.php @@ -13,10 +13,8 @@ namespace Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate; use Chill\DocStoreBundle\Entity\StoredObject; -use Chill\MainBundle\Doctrine\Model\TrackCreationInterface; -use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface; -use Chill\MainBundle\Entity\User; -use DateTimeInterface; +use Chill\MainBundle\Doctrine\Model\TrackCreationTrait; +use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait; use Doctrine\ORM\Mapping as ORM; use RuntimeException; use Symfony\Component\Serializer\Annotation as Serializer; @@ -31,6 +29,10 @@ use Symfony\Component\Validator\Constraints as Assert; */ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doctrine\Model\TrackCreationInterface, \Chill\MainBundle\Doctrine\Model\TrackUpdateInterface { + use TrackCreationTrait; + + use TrackUpdateTrait; + /** * @ORM\ManyToOne( * targetEntity=AccompanyingPeriodWorkEvaluation::class, @@ -39,22 +41,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct */ private ?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation = null; - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - */ - private ?\DateTimeImmutable $createdAt = null; - - /** - * @ORM\ManyToOne( - * targetEntity=User::class - * ) - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - */ - private ?User $createdBy = null; - /** * @ORM\Id * @ORM\GeneratedValue @@ -110,40 +96,11 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct */ private ?string $title = ''; - /** - * @ORM\Column(type="datetime_immutable", nullable=true, options={"default": null}) - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - */ - private ?\DateTimeImmutable $updatedAt = null; - - /** - * @ORM\ManyToOne( - * targetEntity=User::class - * ) - * @Serializer\Groups({"read"}) - * @Serializer\Groups({"accompanying_period_work_evaluation:create"}) - */ - private ?User $updatedBy = null; - public function getAccompanyingPeriodWorkEvaluation(): ?AccompanyingPeriodWorkEvaluation { return $this->accompanyingPeriodWorkEvaluation; } - /** - * @return \DateTimeImmutable|null - */ - public function getCreatedAt(): ?DateTimeInterface - { - return $this->createdAt; - } - - public function getCreatedBy(): ?User - { - return $this->createdBy; - } - public function getId(): ?int { return $this->id; @@ -172,19 +129,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct return $this->title; } - /** - * @return DateTimeImmutable|null - */ - public function getUpdatedAt(): ?DateTimeInterface - { - return $this->updatedAt; - } - - public function getUpdatedBy(): ?User - { - return $this->updatedBy; - } - public function setAccompanyingPeriodWorkEvaluation(?AccompanyingPeriodWorkEvaluation $accompanyingPeriodWorkEvaluation): AccompanyingPeriodWorkEvaluationDocument { // if an evaluation is already associated, we cannot change the association (removing the association, @@ -202,20 +146,6 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct return $this; } - public function setCreatedAt(DateTimeInterface $datetime): TrackCreationInterface - { - $this->createdAt = $datetime; - - return $this; - } - - public function setCreatedBy(User $user): TrackCreationInterface - { - $this->createdBy = $user; - - return $this; - } - /** * @param mixed $key * @@ -248,18 +178,4 @@ class AccompanyingPeriodWorkEvaluationDocument implements \Chill\MainBundle\Doct return $this; } - - public function setUpdatedAt(DateTimeInterface $datetime): TrackUpdateInterface - { - $this->updatedAt = $datetime; - - return $this; - } - - public function setUpdatedBy(User $user): TrackUpdateInterface - { - $this->updatedBy = $user; - - return $this; - } }