mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-19 08:44:24 +00:00
fix bug on redirection when all required participation already exists
When we request multiple participations on an event, and all people already participate on the event, the controller redirected to a route which provoked a bad request error. Now, we redirect to the view route.
This commit is contained in:
parent
e723aeeeb4
commit
54ac8d052f
@ -156,18 +156,19 @@ class ParticipationController extends Controller
|
||||
{
|
||||
$participations = $this->handleRequest($request, new Participation());
|
||||
|
||||
|
||||
foreach ($participations as $i => $participation) {
|
||||
// check for authorization
|
||||
$this->denyAccessUnlessGranted(ParticipationVoter::CREATE,
|
||||
$participation, 'The user is not allowed to create this participation');
|
||||
|
||||
// check that the user is not already in the event (computing only once)
|
||||
// create a collection of person's id participating to the event
|
||||
/* @var $peopleParticipating \Doctrine\Common\Collections\ArrayCollection */
|
||||
$peopleParticipating = isset($peopleParticipating) ? $peopleParticipating :
|
||||
$participation->getEvent()->getParticipations()->map(
|
||||
function(Participation $p) { return $p->getPerson()->getId(); }
|
||||
);
|
||||
|
||||
// check that the user is not already in the event
|
||||
if ($peopleParticipating->contains($participation->getPerson()->getId())) {
|
||||
$ignoredParticipations[] = $participation
|
||||
->getEvent()->getParticipations()->filter(
|
||||
@ -184,10 +185,11 @@ class ParticipationController extends Controller
|
||||
|
||||
if (!isset($newParticipations)) {
|
||||
// if we do not have nay participants, redirect to event view
|
||||
$this->addFlash('error', 'Any of the requested people may be added '
|
||||
. 'on the event: they are maybe already participating.');
|
||||
$this->addFlash('error', $this->get('translator')->trans(
|
||||
'None of the requested people may participate '
|
||||
. 'the event: they are maybe already participating.'));
|
||||
|
||||
return $this->redirectToRoute('chill_event_participation_new', array(
|
||||
return $this->redirectToRoute('chill_event__event_show', array(
|
||||
'event_id' => $request->query->getInt('event_id', 0)
|
||||
));
|
||||
} elseif (count($newParticipations) > 1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user