diff --git a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php index d23aab5..3c83ff1 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php +++ b/src/Hackspace/Bundle/CalciferBundle/Controller/EventController.php @@ -268,4 +268,41 @@ class EventController extends Controller } return $em; } + + /** + * Deletes a Event entity. + * + * @Route("/termine/{slug}/löschen", name="_delete") + * @Method({"GET", "POST"}) + * @Template("CalciferBundle:Event:delete.html.twig") + */ + public function deleteAction(Request $request, $slug) { + /** @var EntityManager $em */ + $em = $this->getDoctrine()->getManager(); + + /** @var EntityRepository $repo */ + $repo = $em->getRepository('CalciferBundle:Event'); + + /** @var Event $entity */ + $entity = $repo->findOneBy(['slug' => $slug]); + + if (!$entity) { + throw $this->createNotFoundException('Unable to find Event entity.'); + } + + + $confirmation = $request->get('confirmation',false); + + if (($request->getMethod() == 'POST') && ($confirmation)) { + $em->remove($entity); + $em->flush(); + + return $this->redirect('/'); + } + + return array( + 'entity' => $entity, + + ); + } } diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss index 0dff5a8..b109b51 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/assets/css/events.scss @@ -6,7 +6,7 @@ } } - .startdate,.location,.url,.edit { + .startdate,.location,.url,.edit,.delete { display: inline; margin: 0; margin-right: 0.5rem; diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/delete.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/delete.html.twig new file mode 100755 index 0000000..66a4061 --- /dev/null +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/delete.html.twig @@ -0,0 +1,29 @@ +{% extends 'CalciferBundle::layout.html.twig' %} + +{% block css %} + {% stylesheets filter="compass" + "@CalciferBundle/Resources/assets/css/events.scss" %} + + {% endstylesheets %} +{% endblock %} + +{% block javascripts %} + {% javascripts + "@CalciferBundle/Resources/assets/js/events.js" %} + + {% endjavascripts %} +{% endblock %} + +{% block body -%} +
+
+
+
+

Möchtest du die Veranstaltung „{{ entity.summary }}“ zum Datum „{{ entity.startdate.format('Y-m-d H:i') }}“ wirklich löschen?

+ + Nein +
+
+
+
+{% endblock %} \ No newline at end of file diff --git a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig index fbf734a..a74377a 100755 --- a/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig +++ b/src/Hackspace/Bundle/CalciferBundle/Resources/views/Event/event_box.html.twig @@ -9,6 +9,13 @@ Bearbeiten

+ +

+ + + Löschen + +

{% endif %}