mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
adding remove event feature
This commit is contained in:
parent
8618efc35a
commit
30e0c663dc
@ -30,7 +30,6 @@ use PhpOffice\PhpSpreadsheet\Writer\Ods;
|
|||||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
|
||||||
use Chill\EventBundle\Security\Authorization\EventVoter;
|
use Chill\EventBundle\Security\Authorization\EventVoter;
|
||||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
@ -49,6 +48,7 @@ use Chill\MainBundle\Entity\Center;
|
|||||||
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||||||
use Symfony\Component\Form\FormFactoryInterface;
|
use Symfony\Component\Form\FormFactoryInterface;
|
||||||
use Symfony\Component\Translation\TranslatorInterface;
|
use Symfony\Component\Translation\TranslatorInterface;
|
||||||
|
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,7 +210,7 @@ class EventController extends Controller
|
|||||||
/**
|
/**
|
||||||
* Finds and displays a Event entity.
|
* Finds and displays a Event entity.
|
||||||
*
|
*
|
||||||
* @paramConverter("event", options={"id" = "event_id"})
|
* @ParamConverter("event", options={"id" = "event_id"})
|
||||||
* @param Event $event
|
* @param Event $event
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return \Symfony\Component\HttpFoundation\Response
|
* @return \Symfony\Component\HttpFoundation\Response
|
||||||
@ -604,4 +604,69 @@ class EventController extends Controller
|
|||||||
return $spreadsheet;
|
return $spreadsheet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $event_id
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
|
||||||
|
*/
|
||||||
|
public function deleteAction($event_id, Request $request)
|
||||||
|
{
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$event = $em->getRepository('ChillEventBundle:Event')->findOneBy([
|
||||||
|
'id' => $event_id
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (! $event) {
|
||||||
|
throw $this->createNotFoundException('Unable to find this event.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var array $participations */
|
||||||
|
$participations = $event->getParticipations();
|
||||||
|
|
||||||
|
$form = $this->createDeleteForm($event_id);
|
||||||
|
|
||||||
|
if ($request->getMethod() === Request::METHOD_DELETE) {
|
||||||
|
$form->handleRequest($request);
|
||||||
|
|
||||||
|
if ($form->isValid()) {
|
||||||
|
|
||||||
|
foreach ($participations as $participation) {
|
||||||
|
$em->remove($participation);
|
||||||
|
}
|
||||||
|
|
||||||
|
$em->remove($event);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$this->addFlash('success', $this->get('translator')
|
||||||
|
->trans("The event has been sucessfully removed")
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this->redirectToRoute('chill_main_search', [
|
||||||
|
'name' => 'event_regular',
|
||||||
|
'q' => '@event'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $this->render('ChillEventBundle:Event:confirm_delete.html.twig', [
|
||||||
|
'event_id' => $event->getId(),
|
||||||
|
'delete_form' => $form->createView()
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $event_id
|
||||||
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
|
*/
|
||||||
|
private function createDeleteForm($event_id)
|
||||||
|
{
|
||||||
|
return $this->createFormBuilder()
|
||||||
|
->setAction($this->generateUrl('chill_event__event_delete', [
|
||||||
|
'event_id' => $event_id
|
||||||
|
]))
|
||||||
|
->setMethod('DELETE')
|
||||||
|
->add('submit', SubmitType::class, ['label' => 'Delete'])
|
||||||
|
->getForm()
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
|
|
||||||
namespace Chill\EventBundle\Controller;
|
namespace Chill\EventBundle\Controller;
|
||||||
|
|
||||||
|
use ArrayIterator;
|
||||||
use Chill\EventBundle\Entity\Event;
|
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;
|
||||||
@ -31,8 +31,9 @@ use Chill\EventBundle\Security\Authorization\ParticipationVoter;
|
|||||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Class ParticipationController
|
||||||
*
|
*
|
||||||
|
* @package Chill\EventBundle\Controller
|
||||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
*/
|
*/
|
||||||
class ParticipationController extends Controller
|
class ParticipationController extends Controller
|
||||||
@ -44,9 +45,9 @@ class ParticipationController extends Controller
|
|||||||
* This function parse the person_id / persons_ids query argument
|
* This function parse the person_id / persons_ids query argument
|
||||||
* and decide if it should process a single or multiple participation. Depending
|
* and decide if it should process a single or multiple participation. Depending
|
||||||
* on this, the appropriate layout and form.
|
* on this, the appropriate layout and form.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
*/
|
*/
|
||||||
public function newAction(Request $request)
|
public function newAction(Request $request)
|
||||||
{
|
{
|
||||||
@ -158,9 +159,9 @@ class ParticipationController extends Controller
|
|||||||
*
|
*
|
||||||
* If all participations must be ignored, an error is shown and the method redirects
|
* If all participations must be ignored, an error is shown and the method redirects
|
||||||
* to the event 'show' view with an appropriate flash message.
|
* to the event 'show' view with an appropriate flash message.
|
||||||
*
|
*
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
* @return Response
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
*/
|
*/
|
||||||
protected function newMultiple(Request $request)
|
protected function newMultiple(Request $request)
|
||||||
{
|
{
|
||||||
@ -224,6 +225,10 @@ class ParticipationController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request)
|
||||||
{
|
{
|
||||||
// test the request is correct
|
// test the request is correct
|
||||||
@ -257,6 +262,10 @@ class ParticipationController extends Controller
|
|||||||
. "'persons_ids' argument in query");
|
. "'persons_ids' argument in query");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
*/
|
||||||
public function createSingle(Request $request)
|
public function createSingle(Request $request)
|
||||||
{
|
{
|
||||||
$participation = $this->handleRequest($request, new Participation(), false);
|
$participation = $this->handleRequest($request, new Participation(), false);
|
||||||
@ -295,6 +304,10 @@ class ParticipationController extends Controller
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
*/
|
||||||
public function createMultiple(Request $request)
|
public function createMultiple(Request $request)
|
||||||
{
|
{
|
||||||
$participations = $this->handleRequest($request, new Participation(), true);
|
$participations = $this->handleRequest($request, new Participation(), true);
|
||||||
@ -431,9 +444,8 @@ class ParticipationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param array $participations
|
* @param array $participations
|
||||||
* @return type
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
public function createCreateFormMultiple(array $participations)
|
public function createCreateFormMultiple(array $participations)
|
||||||
{
|
{
|
||||||
@ -491,6 +503,11 @@ class ParticipationController extends Controller
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $participation_id
|
||||||
|
* @param Request $request
|
||||||
|
* @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
|
||||||
|
*/
|
||||||
public function updateAction($participation_id, Request $request)
|
public function updateAction($participation_id, Request $request)
|
||||||
{
|
{
|
||||||
/* @var $participation Participation */
|
/* @var $participation Participation */
|
||||||
@ -640,15 +657,12 @@ class ParticipationController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param ArrayIterator $participations
|
||||||
* @param \Doctrine\Common\Collections\Collection $participations contains object of Participation type
|
* @param Event $event
|
||||||
* @param \Chill\EventBundle\Entity\Event $event
|
|
||||||
* @return \Symfony\Component\Form\FormInterface
|
* @return \Symfony\Component\Form\FormInterface
|
||||||
*/
|
*/
|
||||||
protected function createEditFormMultiple(
|
protected function createEditFormMultiple(ArrayIterator $participations, Event $event)
|
||||||
\Doctrine\Common\Collections\Collection $participations,
|
{
|
||||||
\Chill\EventBundle\Entity\Event $event
|
|
||||||
) {
|
|
||||||
$form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class,
|
$form = $this->createForm(\Symfony\Component\Form\Extension\Core\Type\FormType::class,
|
||||||
array('participations' => $participations), array(
|
array('participations' => $participations), array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
@ -710,7 +724,7 @@ class ParticipationController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->render('ChillEventBundle:Event:confirm_delete.html.twig', [
|
return $this->render('ChillEventBundle:Participation:confirm_delete.html.twig', [
|
||||||
'event_id' => $event->getId(),
|
'event_id' => $event->getId(),
|
||||||
'delete_form' => $form->createView()
|
'delete_form' => $form->createView()
|
||||||
]);
|
]);
|
||||||
|
@ -41,3 +41,9 @@ chill_event__list_by_person:
|
|||||||
defaults: { _controller: "ChillEventBundle:Event:listByPerson" }
|
defaults: { _controller: "ChillEventBundle:Event:listByPerson" }
|
||||||
methods: [ GET ]
|
methods: [ GET ]
|
||||||
|
|
||||||
|
chill_event__event_delete:
|
||||||
|
path: /{event_id}/delete
|
||||||
|
requirements:
|
||||||
|
event_id: \d+
|
||||||
|
defaults: { _controller: "ChillEventBundle:Event:delete" }
|
||||||
|
methods: [ GET, DELETE ]
|
@ -44,11 +44,13 @@ The participation was updated: La participation a été mise à jour
|
|||||||
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 participation has been sucessfully removed: La participation a été correctement supprimée.
|
||||||
|
The event has been sucessfully removed: L'événement et toutes les participations associées ont été correctement supprimées.
|
||||||
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
|
Remove participation: Supprimer la participation
|
||||||
|
Delete event: Supprimer l'événement
|
||||||
Are you sure you want to remove that participation ?: Êtes-vous certain de vouloir supprimer cette participation ?
|
Are you sure you want to remove that participation ?: Êtes-vous certain de vouloir supprimer cette participation ?
|
||||||
|
Are you sure you want to remove that event ?: Êtes-vous certain de vouloir supprimer cet événement, ainsi que toutes les participations associées ?
|
||||||
|
|
||||||
#search
|
#search
|
||||||
Event search: Recherche d'événements
|
Event search: Recherche d'événements
|
||||||
|
@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
{% set activeRouteKey = 'chill_event__event_show' %}
|
{% set activeRouteKey = 'chill_event__event_show' %}
|
||||||
|
|
||||||
{% block title 'Remove participation'|trans %}
|
{% block title 'Delete event'|trans %}
|
||||||
|
|
||||||
{% block event_content %}
|
{% block event_content %}
|
||||||
|
|
||||||
{{ include('ChillMainBundle:Util:confirmation_template.html.twig',
|
{{ include('ChillMainBundle:Util:confirmation_template.html.twig',
|
||||||
{
|
{
|
||||||
'title' : 'Remove participation'|trans,
|
'title' : 'Delete event'|trans,
|
||||||
'confirm_question' : 'Are you sure you want to remove that participation ?'|trans,
|
'confirm_question' : 'Are you sure you want to remove that event ?'|trans,
|
||||||
'cancel_route' : activeRouteKey,
|
'cancel_route' : activeRouteKey,
|
||||||
'cancel_parameters' : { 'event_id' : event_id },
|
'cancel_parameters' : { 'event_id' : event_id },
|
||||||
'form' : delete_form
|
'form' : delete_form
|
||||||
|
@ -57,6 +57,10 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<li>
|
||||||
|
<a href="{{ path('chill_event__event_delete', {'event_id' : event.id } ) }}"
|
||||||
|
class="sc-button bt-delete">{{ 'Delete event'|trans }}</a>
|
||||||
|
</li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@ -87,13 +91,11 @@
|
|||||||
{% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
|
{% if is_granted('CHILL_EVENT_PARTICIPATION_UPDATE', participation) %}
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_event_participation_edit', { 'participation_id' : participation.id } ) }}"
|
<a href="{{ path('chill_event_participation_edit', { 'participation_id' : participation.id } ) }}"
|
||||||
class="sc-button bt-edit">
|
class="sc-button bt-edit" title="{{ 'Edit'|trans }}"></a>
|
||||||
{{ 'Edit'|trans }}
|
|
||||||
</a>
|
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{{ path('chill_event_participation_delete', {'participation_id' : participation.id } ) }}"
|
<a href="{{ path('chill_event_participation_delete', {'participation_id' : participation.id } ) }}"
|
||||||
class="sc-button bt-delete"></a>
|
class="sc-button bt-delete" title="{{ 'Delete'|trans }}"></a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
20
Resources/views/Participation/confirm_delete.html.twig
Normal file
20
Resources/views/Participation/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 %}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user