Implemented deletion of events.

Fixes #16
This commit is contained in:
Tim Schumacher 2014-09-17 17:37:54 +02:00
parent 405b19b157
commit e8c94262d0
4 changed files with 74 additions and 1 deletions

View file

@ -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,
);
}
}

View file

@ -6,7 +6,7 @@
}
}
.startdate,.location,.url,.edit {
.startdate,.location,.url,.edit,.delete {
display: inline;
margin: 0;
margin-right: 0.5rem;

View file

@ -0,0 +1,29 @@
{% extends 'CalciferBundle::layout.html.twig' %}
{% block css %}
{% stylesheets filter="compass"
"@CalciferBundle/Resources/assets/css/events.scss" %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}
{% endblock %}
{% block javascripts %}
{% javascripts
"@CalciferBundle/Resources/assets/js/events.js" %}
<script src="{{ asset_url }}"></script>
{% endjavascripts %}
{% endblock %}
{% block body -%}
<div class="ui one column page grid">
<div class="ui column">
<div class="ui segment event box">
<form class="ui form" method="post">
<p>Möchtest du die Veranstaltung <strong>„{{ entity.summary }}“</strong> zum Datum <strong>„{{ entity.startdate.format('Y-m-d H:i') }}“</strong> wirklich löschen?</p>
<button name="confirmation" value="true" class="ui button red">Ja</button>
<a href="{{ path('_show', {'slug' : entity.slug }) }}" class="ui button green">Nein</a>
</form>
</div>
</div>
</div>
{% endblock %}

View file

@ -9,6 +9,13 @@
<a href="{{ path('_edit', {'slug' : entity.slug }) }}"><i
class="circular icon edit green inverted link"></i>Bearbeiten</a>
</p>
<p class="delete">
<a href="{{ path('_delete', {'slug' : entity.slug }) }}">
<i class="circular icon delete green inverted link"></i>
Löschen
</a>
</p>
{% endif %}
<p class="startdate ">