mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
fix somes validation and acompanying period voter
This commit is contained in:
@@ -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(
|
||||
|
Reference in New Issue
Block a user