mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
fixes
This commit is contained in:
@@ -31,6 +31,7 @@ use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use DateInterval;
|
||||
use DateTimeImmutable;
|
||||
use JsonSchema\Exception\ValidationException;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\HttpFoundation\Exception\BadRequestException;
|
||||
@@ -323,13 +324,21 @@ final class AccompanyingCourseApiController extends ApiController
|
||||
* @Route("/api/1.0/person/accompanying-course/{id}/confidential.json", name="chill_api_person_accompanying_period_confidential")
|
||||
* @ParamConverter("accompanyingCourse", options={"id": "id"})
|
||||
*/
|
||||
public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, Request $request)
|
||||
public function toggleConfidentialApi(AccompanyingPeriod $accompanyingCourse, $id, Request $request)
|
||||
{
|
||||
if ($request->getMethod() === 'POST') {
|
||||
if ($request->getMethod() == 'POST') {
|
||||
$this->denyAccessUnlessGranted(AccompanyingPeriodVoter::TOGGLE_CONFIDENTIAL, $accompanyingCourse);
|
||||
|
||||
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
if (null != $accompanyingCourse->getUser() && $this->getUser() == $accompanyingCourse->getUser()) {
|
||||
$accompanyingCourse->setConfidential(!$accompanyingCourse->isConfidential());
|
||||
$this->getDoctrine()->getManager()->flush();
|
||||
} else {
|
||||
if ($accompanyingCourse->getUser() == null) {
|
||||
throw new ValidationException("The parcours must have a referrer to be set to confidential");
|
||||
}
|
||||
throw new ValidationException("Only the referrer can set a parcours to confidential");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this->json($accompanyingCourse->isConfidential(), Response::HTTP_OK, [], ['groups' => ['read']]);
|
||||
|
Reference in New Issue
Block a user