mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge remote-tracking branch 'origin/master' into issue582_docgen_person
This commit is contained in:
commit
fedcf7272c
13
CHANGELOG.md
13
CHANGELOG.md
@ -13,12 +13,20 @@ and this project adheres to
|
||||
<!-- write down unreleased development here -->
|
||||
* [person] prevent circular references in PersonDocGenNormalizer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/527)
|
||||
* [person] add maritalStatusComment to PersonDocGenNormalizer (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/582)
|
||||
* Load relationships without gender in french fixtures
|
||||
* Add command to remove old draft accompanying periods
|
||||
|
||||
|
||||
|
||||
## Test releases
|
||||
|
||||
### 2021-04-28
|
||||
|
||||
* [address] fix bug when editing address: update location and addressreferenceId + better update of the map in edition (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/593)
|
||||
* [main] avoid address reference search on undefined post code (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/561)
|
||||
* [person] prevent duplicate relationship in filiation/household graph (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/560)
|
||||
* [Documents] Validate storedObject and allow for null data (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/565)
|
||||
|
||||
## Test releases
|
||||
* [parcours]: Comments can be unpinned + edit/delete for all users that are allowed to edit parcours (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/566)
|
||||
|
||||
### 2021-04-26
|
||||
|
||||
@ -44,6 +52,7 @@ and this project adheres to
|
||||
* [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
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -628,6 +628,10 @@ export default {
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'addressReference': this.entity.selected.address.addressReference
|
||||
});
|
||||
} else {
|
||||
newAddress = Object.assign(newAddress, {
|
||||
'addressReference': null
|
||||
});
|
||||
}
|
||||
|
||||
if (this.validFrom) {
|
||||
|
@ -8,12 +8,15 @@ import L from 'leaflet';
|
||||
import markerIconPng from 'leaflet/dist/images/marker-icon.png'
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
|
||||
let map;
|
||||
let marker;
|
||||
|
||||
export default {
|
||||
name: 'AddressMap',
|
||||
props: ['entity'],
|
||||
data() {
|
||||
return {
|
||||
map: null,
|
||||
marker: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
center() {
|
||||
return this.entity.selected.addressMap.center;
|
||||
@ -21,30 +24,33 @@ export default {
|
||||
},
|
||||
methods:{
|
||||
init() {
|
||||
map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
||||
this.map = L.map('address_map').setView([46.67059, -1.42683], 12);
|
||||
|
||||
map.scrollWheelZoom.disable();
|
||||
this.map.scrollWheelZoom.disable();
|
||||
|
||||
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
|
||||
}).addTo(map);
|
||||
}).addTo(this.map);
|
||||
|
||||
const markerIcon = L.icon({
|
||||
iconUrl: markerIconPng,
|
||||
iconAnchor: [12, 41],
|
||||
});
|
||||
|
||||
marker = L.marker([48.8589, 2.3469], {icon: markerIcon}).addTo(map);
|
||||
|
||||
this.marker = L.marker([48.8589, 2.3469], {icon: markerIcon});
|
||||
this.marker.addTo(this.map);
|
||||
},
|
||||
update() {
|
||||
//console.log('update map with : ', this.address.addressMap.center)
|
||||
marker.setLatLng(this.entity.addressMap.center);
|
||||
map.setView(this.entity.addressMap.center, 15);
|
||||
//console.log('update map with : ', this.entity.addressMap.center)
|
||||
if (this.marker && this.entity.addressMap.center) {
|
||||
this.marker.setLatLng(this.entity.addressMap.center);
|
||||
this.map.setView(this.entity.addressMap.center, 15);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted(){
|
||||
this.init()
|
||||
this.init();
|
||||
this.update();
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -106,6 +106,9 @@ export default {
|
||||
this.$emit('getReferenceAddresses', this.value);
|
||||
if (this.value.center) {
|
||||
this.updateMapCenter(this.value.center);
|
||||
if (this.value.center.coordinates) {
|
||||
this.entity.selected.postcode.coordinates = this.value.center.coordinates;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -71,6 +71,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
'id' => $address->getPostCode()->getId(),
|
||||
'name' => $address->getPostCode()->getName(),
|
||||
'code' => $address->getPostCode()->getCode(),
|
||||
'center' => $address->getPostcode()->getCenter(),
|
||||
],
|
||||
'country' => [
|
||||
'id' => $address->getPostCode()->getCountry()->getId(),
|
||||
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Command;
|
||||
|
||||
use Chill\PersonBundle\Service\AccompanyingPeriod\OldDraftAccompanyingPeriodRemoverInterface;
|
||||
use DateInterval;
|
||||
use Exception;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class RemoveOldDraftAccompanyingPeriodCommand extends Command
|
||||
{
|
||||
private LoggerInterface $logger;
|
||||
|
||||
private OldDraftAccompanyingPeriodRemoverInterface $remover;
|
||||
|
||||
public function __construct(LoggerInterface $logger, OldDraftAccompanyingPeriodRemoverInterface $remover)
|
||||
{
|
||||
parent::__construct('chill:person:remove-old-draft-period');
|
||||
|
||||
$this->logger = $logger;
|
||||
$this->remover = $remover;
|
||||
}
|
||||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this
|
||||
->setDescription('Remove draft accompanying period which are still draft and unused')
|
||||
->addArgument('interval', InputArgument::OPTIONAL, 'The interval for unactive periods', 'P15D');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$this->logger->info('[' . $this->getName() . '] started', [
|
||||
'interval' => $input->getArgument('interval'),
|
||||
]);
|
||||
|
||||
try {
|
||||
$interval = new DateInterval($input->getArgument('interval'));
|
||||
} catch (Exception $e) {
|
||||
$this->logger->error('[' . $this->getName() . '] bad interval');
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
$this->remover->remove($interval);
|
||||
|
||||
$this->logger->info('[' . $this->getName() . '] end of command');
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -186,6 +186,24 @@ class AccompanyingCourseCommentController extends AbstractController
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Route("/{_locale}/parcours/comment/{id}/unpin", name="chill_person_accompanying_period_comment_unpin")
|
||||
*/
|
||||
public function unpinComment(AccompanyingPeriod\Comment $comment): Response
|
||||
{
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::EDIT, $comment->getAccompanyingPeriod());
|
||||
|
||||
$comment->getAccompanyingPeriod()->setPinnedComment(null);
|
||||
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
|
||||
$this->addFlash('success', $this->translator->trans('accompanying_course.comment is unpinned'));
|
||||
|
||||
return $this->redirectToRoute('chill_person_accompanying_period_comment_list', [
|
||||
'accompanying_period_id' => $comment->getAccompanyingPeriod()->getId(),
|
||||
]);
|
||||
}
|
||||
|
||||
private function createCommentForm(AccompanyingPeriod\Comment $comment, string $step): FormInterface
|
||||
{
|
||||
return $this->formFactory->createNamed($step, AccompanyingCourseCommentType::class, $comment);
|
||||
|
@ -21,23 +21,13 @@ class LoadRelations extends Fixture implements FixtureGroupInterface
|
||||
public const RELATION_KEY = 'relations';
|
||||
|
||||
public const RELATIONS = [
|
||||
['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fille']],
|
||||
['title' => ['fr' => 'Mère'], 'reverseTitle' => ['fr' => 'Fils']],
|
||||
['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fille']],
|
||||
['title' => ['fr' => 'Père'], 'reverseTitle' => ['fr' => 'Fils']],
|
||||
|
||||
['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Frère']],
|
||||
['title' => ['fr' => 'Soeur'], 'reverseTitle' => ['fr' => 'Soeur']],
|
||||
['title' => ['fr' => 'Frère'], 'reverseTitle' => ['fr' => 'Soeur']],
|
||||
|
||||
['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-frère']],
|
||||
['title' => ['fr' => 'Demi-soeur'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
|
||||
['title' => ['fr' => 'Demi-frère'], 'reverseTitle' => ['fr' => 'Demi-soeur']],
|
||||
|
||||
['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Neveu']],
|
||||
['title' => ['fr' => 'Oncle'], 'reverseTitle' => ['fr' => 'Nièce']],
|
||||
['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Neveu']],
|
||||
['title' => ['fr' => 'Tante'], 'reverseTitle' => ['fr' => 'Nièce']],
|
||||
['title' => ['fr' => 'Parent'], 'reverseTitle' => ['fr' => 'Enfant']],
|
||||
['title' => ['fr' => 'En couple'], 'reverseTitle' => ['fr' => 'En couple']],
|
||||
['title' => ['fr' => 'Beau parent'], 'reverseTitle' => ['fr' => 'Belle-fille·beau-fils']],
|
||||
['title' => ['fr' => 'Frère·Sœur'], 'reverseTitle' => ['fr' => 'Frère·Sœur']],
|
||||
['title' => ['fr' => 'Demi-frère·sœur'], 'reverseTitle' => ['fr' => 'Demi-frère·sœur']],
|
||||
['title' => ['fr' => 'Grand-parent'], 'reverseTitle' => ['fr' => 'Petit-enfant']],
|
||||
['title' => ['fr' => 'Oncle·Tante'], 'reverseTitle' => ['fr' => 'Neveu·Nièce']],
|
||||
];
|
||||
|
||||
public static function getGroups(): array
|
||||
|
@ -1258,10 +1258,6 @@ class AccompanyingPeriod implements
|
||||
*/
|
||||
public function setPinnedComment(?Comment $comment = null): self
|
||||
{
|
||||
if (null !== $this->pinnedComment) {
|
||||
$this->removeComment($this->pinnedComment);
|
||||
}
|
||||
|
||||
if (null !== $this->pinnedComment) {
|
||||
$this->addComment($this->pinnedComment);
|
||||
}
|
||||
|
@ -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="date_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="date_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;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,17 @@
|
||||
|
||||
{% macro recordAction(comment, isPinned) %}
|
||||
{% if isPinned is defined and isPinned == true %}
|
||||
<li>
|
||||
<form method="post" action="{{ chill_path_forward_return_path('chill_person_accompanying_period_comment_unpin', {'id': comment.id}) }}">
|
||||
<button class="btn btn-sm btn-misc" type="submit">
|
||||
<span class="fa-stack">
|
||||
<i class="fa fa-flag fa-stack-1x"></i>
|
||||
<i class="fa fa-ban fa-stack-2x text-danger"></i>
|
||||
</span>
|
||||
{{ 'Unpin comment'|trans }}
|
||||
</button>
|
||||
</form>
|
||||
</li>
|
||||
{% else %}
|
||||
<li>
|
||||
<form method="post" action="{{ chill_path_forward_return_path('chill_person_accompanying_period_comment_pin', {'id': comment.id}) }}">
|
||||
@ -17,7 +28,7 @@
|
||||
</form>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT', comment) %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', comment.accompanyingPeriod) %}
|
||||
<li>
|
||||
<a class="btn btn-sm btn-edit" title="{{ 'Edit'|trans }}" href="{{ path('chill_person_accompanying_period_comment_list', {
|
||||
'_fragment': 'comment-' ~ comment.id,
|
||||
@ -26,7 +37,7 @@
|
||||
}) }}"></a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_DELETE', comment) %}
|
||||
{% if is_granted('CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE', comment.accompanyingPeriod) %}
|
||||
<li>
|
||||
<a class="btn btn-sm btn-delete" title="{{ 'Delete'|trans }}" href="{{ path('chill_person_accompanying_period_comment_delete', {'id': comment.id}) }}"></a>
|
||||
</li>
|
||||
|
@ -14,6 +14,7 @@ namespace Chill\PersonBundle\Security\Authorization;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod\Comment;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use UnexpectedValueException;
|
||||
|
||||
class AccompanyingPeriodCommentVoter extends Voter
|
||||
@ -22,6 +23,13 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
|
||||
public const EDIT = 'CHILL_PERSON_ACCOMPANYING_PERIOD_COMMENT_EDIT';
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(Security $security)
|
||||
{
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
return $subject instanceof Comment;
|
||||
@ -32,8 +40,10 @@ class AccompanyingPeriodCommentVoter extends Voter
|
||||
/** @var Comment $subject */
|
||||
switch ($attribute) {
|
||||
case self::EDIT:
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
case self::DELETE:
|
||||
return $subject->getCreator() === $token->getUser();
|
||||
return $this->security->isGranted(AccompanyingPeriodVoter::EDIT, $subject->getAccompanyingPeriod());
|
||||
|
||||
default:
|
||||
throw new UnexpectedValueException("This attribute {$attribute} is not supported");
|
||||
|
@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\AccompanyingPeriod;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\AccompanyingCourseDocument;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriodParticipation;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\DBAL\Types\Types;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class OldDraftAccompanyingPeriodRemover implements OldDraftAccompanyingPeriodRemoverInterface
|
||||
{
|
||||
private EntityManagerInterface $em;
|
||||
|
||||
private LoggerInterface $logger;
|
||||
|
||||
public function __construct(EntityManagerInterface $em, LoggerInterface $logger)
|
||||
{
|
||||
$this->em = $em;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
||||
public function remove(DateInterval $interval): void
|
||||
{
|
||||
$this->logger->debug('[' . __CLASS__ . '] start to remove old periods', [
|
||||
'interval' => $interval->format('%d days'),
|
||||
]);
|
||||
|
||||
$beforeDate = (new DateTimeImmutable('now'))->sub($interval);
|
||||
|
||||
$results = $this->em->wrapInTransaction(static function (EntityManagerInterface $em) use ($beforeDate) {
|
||||
$subDQL = 'SELECT p FROM ' . AccompanyingPeriod::class . ' p WHERE p.createdAt < :beforeDate AND p.step = :draft';
|
||||
$parameters = [
|
||||
'beforeDate' => $beforeDate,
|
||||
'draft' => AccompanyingPeriod::STEP_DRAFT,
|
||||
];
|
||||
|
||||
$resources = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod\Resource::class . " r WHERE r.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$participations = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriodParticipation::class . " part WHERE part.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$userHistory = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod\UserHistory::class . " h WHERE h.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$comments = $em->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod\Comment::class . " c WHERE c.accompanyingPeriod IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$documents = $em->createQuery(
|
||||
'DELETE ' . AccompanyingCourseDocument::class . " d WHERE d.course IN ({$subDQL})"
|
||||
)
|
||||
->setParameters($parameters)
|
||||
->getSingleScalarResult();
|
||||
|
||||
$periods = $em
|
||||
->createQuery(
|
||||
'DELETE ' . AccompanyingPeriod::class . ' p WHERE p.createdAt < :beforeDate
|
||||
AND p.step = :draft'
|
||||
)
|
||||
->setParameter(':beforeDate', $beforeDate, Types::DATETIME_IMMUTABLE)
|
||||
->setParameter(':draft', AccompanyingPeriod::STEP_DRAFT)
|
||||
->getSingleScalarResult();
|
||||
|
||||
return [
|
||||
'comments' => $comments,
|
||||
'documents' => $documents,
|
||||
'participations' => $participations,
|
||||
'periods' => $periods,
|
||||
'resources' => $resources,
|
||||
'userHistory' => $userHistory,
|
||||
];
|
||||
});
|
||||
|
||||
$this->logger->info('[' . __CLASS__ . '] periods removed', array_merge($results, [
|
||||
'interval' => $interval->format('%d days'),
|
||||
]));
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\PersonBundle\Service\AccompanyingPeriod;
|
||||
|
||||
use DateInterval;
|
||||
|
||||
interface OldDraftAccompanyingPeriodRemoverInterface
|
||||
{
|
||||
public function remove(DateInterval $interval): void;
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20220427150431 extends AbstractMigration
|
||||
{
|
||||
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)\'');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'change date to datetime for evaluation documents';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->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)\'');
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20220429133023 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE "accompanying_periods_scopes"
|
||||
DROP CONSTRAINT "fk_87c4eab032a7a428",
|
||||
ADD CONSTRAINT "fk_87c4eab032a7a428" FOREIGN KEY (accompanying_period_id) REFERENCES chill_person_accompanying_period(id)
|
||||
');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'apply CASCADE DELETE on entity related to accompanying periods';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE "accompanying_periods_scopes"
|
||||
DROP CONSTRAINT "fk_87c4eab032a7a428",
|
||||
ADD CONSTRAINT "fk_87c4eab032a7a428" FOREIGN KEY (accompanying_period_id) REFERENCES chill_person_accompanying_period(id) ON DELETE CASCADE
|
||||
');
|
||||
}
|
||||
}
|
@ -465,6 +465,7 @@ fix it: Compléter
|
||||
accompanying_course:
|
||||
administrative_location: Localisation administrative
|
||||
comment is pinned: Le commentaire est épinglé
|
||||
comment is unpinned: Le commentaire est désépinglé
|
||||
show: Montrer
|
||||
hide: Masquer
|
||||
closed periods: parcours clôturer
|
||||
@ -474,6 +475,7 @@ Accompanying Course Comment: Commentaire
|
||||
Accompanying Course Comment list: Commentaires du parcours
|
||||
pinned: épinglé
|
||||
Pin comment: Épingler
|
||||
Unpin comment: Désépingler
|
||||
Post a new comment: Poster un nouveau commentaire
|
||||
Write a new comment: Écrire un nouveau commentaire
|
||||
Edit a comment: Modifier le commentaire
|
||||
|
Loading…
x
Reference in New Issue
Block a user