Merge branch 'master' into notification/completion

This commit is contained in:
2022-01-10 16:11:06 +01:00
78 changed files with 1268 additions and 277 deletions

View File

@@ -19,6 +19,7 @@ use Chill\PersonBundle\Repository\AccompanyingPeriod\AccompanyingPeriodWorkRepos
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
@@ -110,6 +111,60 @@ class AccompanyingCourseController extends Controller
]);
}
/**
* Delete page of Accompanying Course section.
*
* @Route("/{_locale}/parcours/{accompanying_period_id}/delete", name="chill_person_accompanying_course_delete")
* @ParamConverter("accompanyingCourse", options={"id": "accompanying_period_id"})
*/
public function deleteAction(Request $request, AccompanyingPeriod $accompanyingCourse)
{
$em = $this->getDoctrine()->getManager();
$person_id = $request->query->get('person_id');
$form = $this->createFormBuilder()
->setAction($this->generateUrl('chill_person_accompanying_course_delete', [
'accompanying_period_id' => $accompanyingCourse->getId(),
'person_id' => $person_id,
]))
->setMethod('DELETE')
->add('submit', SubmitType::class, ['label' => 'Delete'])
->getForm();
if ($request->getMethod() === Request::METHOD_DELETE) {
$form->handleRequest($request);
if ($form->isValid()) {
$em->remove($accompanyingCourse);
$em->flush();
$this->addFlash('success', $this->get('translator')
->trans('The accompanying course has been successfully removed.'));
if (null !== $person_id) {
return $this->redirectToRoute('chill_person_accompanying_period_list', [
'person_id' => $person_id,
]);
}
return $this->redirectToRoute('chill_main_homepage');
}
}
if (null !== $person_id) {
$view = '@ChillPerson/AccompanyingCourse/confirm_delete_person.html.twig';
} else {
$view = '@ChillPerson/AccompanyingCourse/confirm_delete_accompanying_course.html.twig';
}
return $this->render($view, [
'accompanyingCourse' => $accompanyingCourse,
'person_id' => $person_id,
'delete_form' => $form->createView(),
]);
}
/**
* Edit page of Accompanying Course section.
*
@@ -208,6 +263,9 @@ class AccompanyingCourseController extends Controller
}
}
$userLocation = $this->getUser()->getCurrentLocation();
$period->setAdministrativeLocation($userLocation);
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::CREATE, $period);
$em->persist($period);