mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-30 14:06:13 +00:00
fix somes validation and acompanying period voter
This commit is contained in:
parent
8113fddcb2
commit
065b10b877
@ -36,6 +36,7 @@ use Symfony\Component\Serializer\SerializerInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Component\Validator\Constraints\NotEqualTo;
|
||||
use Symfony\Component\Validator\Constraints\NotIdenticalTo;
|
||||
use Symfony\Component\Validator\Constraints\NotNull;
|
||||
use function is_int;
|
||||
|
||||
class ReassignAccompanyingPeriodController extends AbstractController
|
||||
@ -116,25 +117,23 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
|
||||
$assignForm->handleRequest($request);
|
||||
|
||||
if ($assignForm->isSubmitted()) {
|
||||
if ($assignForm->isSubmitted()) {
|
||||
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
||||
$userTo = $assignForm->get('userTo')->getData();
|
||||
$userFrom = $assignForm->get('userFrom')->getData();
|
||||
if ($assignForm->isSubmitted() && $assignForm->isValid()) {
|
||||
$assignPeriodIds = json_decode($assignForm->get('periods')->getData(), true);
|
||||
$userTo = $assignForm->get('userTo')->getData();
|
||||
$userFrom = $assignForm->get('userFrom')->getData();
|
||||
|
||||
foreach ($assignPeriodIds as $periodId) {
|
||||
$period = $this->courseRepository->find($periodId);
|
||||
foreach ($assignPeriodIds as $periodId) {
|
||||
$period = $this->courseRepository->find($periodId);
|
||||
|
||||
if ($period->getUser() === $userFrom) {
|
||||
$period->setUser($userTo);
|
||||
}
|
||||
if ($period->getUser() === $userFrom) {
|
||||
$period->setUser($userTo);
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
// redirect to the first page
|
||||
return $this->redirectToRoute('chill_course_list_reassign', $request->query->all());
|
||||
}
|
||||
|
||||
$this->em->flush();
|
||||
|
||||
// redirect to the first page
|
||||
return $this->redirectToRoute('chill_course_list_reassign', $request->query->all());
|
||||
}
|
||||
|
||||
return new Response(
|
||||
@ -178,6 +177,8 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
|
||||
if (null !== $userFrom) {
|
||||
$constraints = [new NotIdenticalTo(['value' => $userFrom])];
|
||||
} else {
|
||||
$constraints = [];
|
||||
}
|
||||
|
||||
$builder
|
||||
@ -188,7 +189,7 @@ class ReassignAccompanyingPeriodController extends AbstractController
|
||||
'label' => 'reassign.Next user',
|
||||
'required' => true,
|
||||
'help' => 'reassign.All periods on this list will be reassigned to this user, excepted the one you manually reassigned before',
|
||||
'constraints' => $constraints ?? [],
|
||||
'constraints' => [new NotNull()],
|
||||
]);
|
||||
|
||||
$builder->get('userFrom')->addModelTransformer(new CallbackTransformer(
|
||||
|
@ -65,15 +65,15 @@ class SectionMenuBuilder implements LocalMenuBuilderInterface
|
||||
]);
|
||||
}
|
||||
|
||||
// if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
||||
$menu->addChild($this->translator->trans('Accompanying courses of users'), [
|
||||
if ($this->authorizationChecker->isGranted(AccompanyingPeriodVoter::REASSIGN_BULK, null)) {
|
||||
$menu->addChild($this->translator->trans('reassign.Bulk reassign'), [
|
||||
'route' => 'chill_course_list_reassign',
|
||||
])
|
||||
->setExtras([
|
||||
'order' => 12,
|
||||
'icons' => ['task'],
|
||||
'order' => 40,
|
||||
'icons' => [],
|
||||
]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
public static function getMenuIds(): array
|
||||
|
@ -25,6 +25,9 @@ use function in_array;
|
||||
|
||||
class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleHierarchyInterface
|
||||
{
|
||||
/**
|
||||
* all the roles that are linked to an accompanying period
|
||||
*/
|
||||
public const ALL = [
|
||||
self::SEE,
|
||||
self::SEE_DETAILS,
|
||||
@ -34,7 +37,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
self::FULL,
|
||||
self::TOGGLE_CONFIDENTIAL_ALL,
|
||||
self::TOGGLE_INTENSITY,
|
||||
self::REASSIGN_BULK,
|
||||
self::RE_OPEN_COURSE,
|
||||
];
|
||||
|
||||
@ -67,6 +69,9 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
*/
|
||||
public const RE_OPEN_COURSE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_REOPEN';
|
||||
|
||||
/**
|
||||
* Allow user to bulk reassign the courses
|
||||
*/
|
||||
public const REASSIGN_BULK = 'CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK';
|
||||
|
||||
public const SEE = 'CHILL_PERSON_ACCOMPANYING_PERIOD_SEE';
|
||||
@ -101,7 +106,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
$this->security = $security;
|
||||
$this->voterHelper = $voterHelperFactory
|
||||
->generate(self::class)
|
||||
->addCheckFor(null, [self::CREATE])
|
||||
->addCheckFor(null, [self::CREATE, self::REASSIGN_BULK])
|
||||
->addCheckFor(AccompanyingPeriod::class, [self::TOGGLE_CONFIDENTIAL, ...self::ALL])
|
||||
->addCheckFor(Person::class, [self::SEE])
|
||||
->build();
|
||||
@ -109,7 +114,16 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
|
||||
public function getRoles(): array
|
||||
{
|
||||
return self::ALL;
|
||||
return [
|
||||
self::SEE,
|
||||
self::SEE_DETAILS,
|
||||
self::CREATE,
|
||||
self::EDIT,
|
||||
self::DELETE,
|
||||
self::FULL,
|
||||
self::TOGGLE_CONFIDENTIAL_ALL,
|
||||
self::REASSIGN_BULK,
|
||||
];
|
||||
}
|
||||
|
||||
public function getRolesWithHierarchy(): array
|
||||
@ -119,7 +133,7 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
|
||||
public function getRolesWithoutScope(): array
|
||||
{
|
||||
return [];
|
||||
return [self::REASSIGN_BULK];
|
||||
}
|
||||
|
||||
protected function supports($attribute, $subject)
|
||||
@ -169,8 +183,11 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($this->voterHelper->voteOnAttribute(self::TOGGLE_CONFIDENTIAL_ALL, $subject, $token)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
// return $this->voterHelper->voteOnAttribute(self::TOGGLE_CONFIDENTIAL_ALL, $subject, $token);
|
||||
}
|
||||
|
||||
if (self::TOGGLE_INTENSITY === $attribute) {
|
||||
@ -181,10 +198,6 @@ class AccompanyingPeriodVoter extends AbstractChillVoter implements ProvideRoleH
|
||||
return false;
|
||||
}
|
||||
|
||||
// if (self::REASSIGN_BULK === $attribute) {
|
||||
|
||||
// }
|
||||
|
||||
// if confidential, only the referent can see it
|
||||
if ($subject->isConfidential()) {
|
||||
return $token->getUser() === $subject->getUser();
|
||||
|
@ -301,7 +301,15 @@ CHILL_PERSON_CREATE: Ajouter des personnes
|
||||
CHILL_PERSON_STATS: Statistiques sur les personnes
|
||||
CHILL_PERSON_LISTS: Liste des personnes
|
||||
CHILL_PERSON_DUPLICATE: Gérer les doublons de personnes
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE: Voir les périodes d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE: Vision simplifiée d'une période d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_DELETE: Supprimer une période d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_RE_OPEN: Ré-ouvrir un parcours clotûré
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_TOGGLE_CONFIDENTIAL_ALL: Modifier la confidentialité de tous les parcours
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_CREATE: Créer une période d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_UPDATE: Modifier une période d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_FULL: Voir les détails, créer, supprimer et mettre à jour une période d'accompagnement
|
||||
CHILL_PERSON_ACCOMPANYING_COURSE_REASSIGN_BULK: Réassigner les parcours en lot
|
||||
CHILL_PERSON_ACCOMPANYING_PERIOD_SEE_DETAILS: Voir les détails d'une période d'accompagnement
|
||||
|
||||
#period
|
||||
Period closed!: Période clôturée!
|
||||
@ -598,6 +606,7 @@ period_by_user_list:
|
||||
Any course or no authorization to see them: Aucun parcours pour ce référent, ou aucun droit pour visualiser les parcours de ce référent.
|
||||
|
||||
reassign:
|
||||
Bulk reassign: Réassigner les parcours
|
||||
Current user: Parcours par référent
|
||||
Next user: Nouveau référent
|
||||
Choose a user and click on "Filter" to apply: Choisissez un utilisateur et cliquez sur "Filtrer" pour visualiser ses parcours
|
||||
|
Loading…
x
Reference in New Issue
Block a user