mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
adding remove participation method
This commit is contained in:
parent
6fe4594d3c
commit
8618efc35a
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
namespace Chill\EventBundle\Controller;
|
namespace Chill\EventBundle\Controller;
|
||||||
|
|
||||||
|
use Chill\EventBundle\Entity\Event;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
@ -551,8 +553,9 @@ class ParticipationController extends Controller
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* show a form to edit multiple participation for the same event.
|
* show a form to edit multiple participation for the same event.
|
||||||
*
|
*
|
||||||
* @param int $event_id
|
* @param int $event_id
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
*/
|
*/
|
||||||
public function editMultipleAction($event_id)
|
public function editMultipleAction($event_id)
|
||||||
{
|
{
|
||||||
@ -637,8 +640,8 @@ class ParticipationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param \Doctrine\Common\Collections\Collectionn $participations contains object of Participation type
|
* @param \Doctrine\Common\Collections\Collection $participations contains object of Participation type
|
||||||
* @param \Chill\EventBundle\Entity\Event $event
|
* @param \Chill\EventBundle\Entity\Event $event
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
@ -669,4 +672,65 @@ class ParticipationController extends Controller
|
|||||||
return $form;
|
return $form;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param integer $participation_id
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
*/
|
||||||
|
public function deleteAction($participation_id, Request $request)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$participation = $em->getRepository('ChillEventBundle:Participation')->findOneBy([
|
||||||
|
'id' => $participation_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (! $participation) {
|
||||||
|
throw $this->createNotFoundException('Unable to find participation.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var Event $event */
|
||||||
|
$event = $participation->getEvent();
|
||||||
|
|
||||||
|
$form = $this->createDeleteForm($participation_id);
|
||||||
|
|
||||||
|
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
|
||||||
|
$em->remove($participation);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->get('translator')
|
||||||
|
->trans("The participation has been sucessfully removed")
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_event__event_show', [
|
||||||
|
'event_id' => $event->getId()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->render('ChillEventBundle:Event:confirm_delete.html.twig', [
|
||||||
|
'event_id' => $event->getId(),
|
||||||
|
'delete_form' => $form->createView()
|
||||||
|
]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $participation_id
|
||||||
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
|
*/
|
||||||
|
private function createDeleteForm($participation_id)
|
||||||
|
{
|
||||||
|
return $this->createFormBuilder()
|
||||||
|
->setAction($this->generateUrl('chill_event_participation_delete', [
|
||||||
|
'participation_id' => $participation_id
|
||||||
|
]))
|
||||||
|
->setMethod('DELETE')
|
||||||
|
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||||
|
->getForm()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,3 +23,11 @@ chill_event_participation_update_multiple:
|
|||||||
path: /{event_id}/update_multiple
|
path: /{event_id}/update_multiple
|
||||||
defaults: { _controller: ChillEventBundle:Participation:updateMultiple }
|
defaults: { _controller: ChillEventBundle:Participation:updateMultiple }
|
||||||
methods: [POST]
|
methods: [POST]
|
||||||
|
|
||||||
|
chill_event_participation_delete:
|
||||||
|
path: /{participation_id}/delete
|
||||||
|
requirements:
|
||||||
|
participation_id: \d+
|
||||||
|
defaults: { _controller: ChillEventBundle:Participation:delete }
|
||||||
|
methods: [ GET, DELETE ]
|
||||||
|
|
||||||
|
@ -43,9 +43,13 @@ The participation was updated: La participation a été mise à jour
|
|||||||
'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement'
|
'The following people have been ignored because they are already participating on the event': '{1} La personne suivante a été ignorée parce qu''elle participe déjà à l''événement | ]1,Inf] Les personnes suivantes ont été ignorées parce qu''elles participent déjà à l''événement'
|
||||||
There are no participation to edit for this event: Il n'y a pas de participation pour cet événement
|
There are no participation to edit for this event: Il n'y a pas de participation pour cet événement
|
||||||
The participations have been successfully updated.: Les participations ont été mises à jour.
|
The participations have been successfully updated.: Les participations ont été mises à jour.
|
||||||
|
The participation has been sucessfully removed: La participation a été correctement supprimée.
|
||||||
The participations were created: Les participations ont été créées
|
The participations were created: Les participations ont été créées
|
||||||
Events participation: Participation aux événements
|
Events participation: Participation aux événements
|
||||||
|
|
||||||
|
Remove participation: Supprimer la participation
|
||||||
|
Are you sure you want to remove that participation ?: Êtes-vous certain de vouloir supprimer cette participation ?
|
||||||
|
|
||||||
#search
|
#search
|
||||||
Event search: Recherche d'événements
|
Event search: Recherche d'événements
|
||||||
'%total% events match the search %pattern%' : '{0} Aucun événement ne correspond aux termes de recherche "%pattern%" | {1} Un événement a été trouvé par la recherche "%pattern%" | ]1,Inf] %total% événements correspondent aux termes de recherche "%pattern%".'
|
'%total% events match the search %pattern%' : '{0} Aucun événement ne correspond aux termes de recherche "%pattern%" | {1} Un événement a été trouvé par la recherche "%pattern%" | ]1,Inf] %total% événements correspondent aux termes de recherche "%pattern%".'
|
||||||
|
20
Resources/views/Event/confirm_delete.html.twig
Normal file
20
Resources/views/Event/confirm_delete.html.twig
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
{% extends 'ChillEventBundle::layout.html.twig' %}
|
||||||
|
|
||||||
|
{% set activeRouteKey = 'chill_event__event_show' %}
|
||||||
|
|
||||||
|
{% block title 'Remove participation'|trans %}
|
||||||
|
|
||||||
|
{% block event_content %}
|
||||||
|
|
||||||
|
{{ include('ChillMainBundle:Util:confirmation_template.html.twig',
|
||||||
|
{
|
||||||
|
'title' : 'Remove participation'|trans,
|
||||||
|
'confirm_question' : 'Are you sure you want to remove that participation ?'|trans,
|
||||||
|
'cancel_route' : activeRouteKey,
|
||||||
|
'cancel_parameters' : { 'event_id' : event_id },
|
||||||
|
'form' : delete_form
|
||||||
|
}
|
||||||
|
) }}
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -91,6 +91,10 @@
|
|||||||
{{ 'Edit'|trans }}
|
{{ 'Edit'|trans }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_event_participation_delete', {'participation_id' : participation.id } ) }}"
|
||||||
|
class="sc-button bt-delete"></a>
|
||||||
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
</td>
|
</td>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user