Add a logging mechanism for repeating events

This commit is contained in:
Tim Schumacher 2016-11-21 21:53:33 +01:00
parent 1cb9949ddd
commit 4dc9021d88
4 changed files with 157 additions and 1 deletions

View file

@ -12,6 +12,7 @@ namespace Hackspace\Bundle\CalciferBundle\Command;
use Doctrine\ORM\EntityManager;
use Hackspace\Bundle\CalciferBundle\Entity\Event;
use Hackspace\Bundle\CalciferBundle\Entity\RepeatingEvent;
use Hackspace\Bundle\CalciferBundle\Entity\RepeatingEventLogEntry;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@ -52,7 +53,6 @@ class GenerateEventsCommand extends ContainerAwareCommand
$event = null;
while (($next_date = $parser->getNext()) < $end) {
/** @var \DateTime $next_date */
$output->writeln(sprintf("Creating Event %s for %s",$entity->summary,$next_date->format('Y-m-d H:i')));
$event = new Event();
$event->location = $entity->location;
$event->startdate = $next_date;
@ -75,6 +75,12 @@ class GenerateEventsCommand extends ContainerAwareCommand
$event->addTag($tag);
}
$entityManager->persist($event);
$logEntry = new RepeatingEventLogEntry();
$logEntry->event = $event;
$logEntry->repeating_event = $entity;
$logEntry->event_startdate = $event->startdate;
$logEntry->event_enddate = $event->enddate;
$entityManager->persist($logEntry);
$entityManager->flush();
$parser->setNow($next_date);
}

View file

@ -48,6 +48,28 @@ class RepeatingEventController extends Controller
];
}
/**
* Displays all repeating events
*
* @Route("/logs", name="repeating_event_logs")
* @Method("GET")
* @Template()
*/
public function logIndexAction()
{
/** @var EntityManager $em */
$em = $this->getDoctrine()->getManager();
/** @var EntityRepository $repo */
$repo = $em->getRepository('CalciferBundle:RepeatingEventLogEntry');
$entities = $repo->findBy([], ['event_startdate' => 'DESC']);
return [
'entities' => $entities,
];
}
/**
* Displays a form to create a repeating event
*

View file

@ -0,0 +1,70 @@
<?php
/**
* Created by PhpStorm.
* User: tim
* Date: 21.11.2016
* Time: 21:15
*/
namespace Hackspace\Bundle\CalciferBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Class RepeatingEventLogEntry
* @package Hackspace\Bundle\CalciferBundle\Entity
*
* @property RepeatingEvent $repeating_event
* @property Event $event
* @property \DateTime $event_startdate
* @property \DateTime $event_enddate
*
* @ORM\Table(name="repeating_events_log_entries")
* @ORM\Entity
*/
class RepeatingEventLogEntry extends BaseEntity
{
/**
* @var integer
*
* @ORM\Column(name="repeating_events_id", type="integer", nullable=false)
*/
protected $repeating_events_id;
/**
* @var RepeatingEvent
*
* @ORM\ManyToOne(targetEntity="RepeatingEvent")
* @ORM\JoinColumn(name="repeating_events_id", referencedColumnName="id")
*/
protected $repeating_event;
/**
* @var string
*
* @ORM\Column(name="events_id", type="integer", nullable=false)
*/
protected $events_id;
/**
* @var Event
*
* @ORM\ManyToOne(targetEntity="Event")
* @ORM\JoinColumn(name="events_id", referencedColumnName="id")
*/
protected $event;
/**
* @var \DateTime
*
* @ORM\Column(name="event_startdate", type="datetimetz")
*/
protected $event_startdate;
/**
* @var \DateTime
*
* @ORM\Column(name="event_enddate", type="datetimetz", nullable=true)
*/
protected $event_enddate;
}

View file

@ -0,0 +1,58 @@
{% 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 basic segment">
<h1 class="ui green block dividing header">
Logeinträge für Wiederholende Termine
</h1>
</div>
<div class="ui basic segment">
<table class="ui table">
<thead>
<tr>
<th>Wiederholender Termin</th>
<th>Termin</th>
<th>Termin Startdatum</th>
<th>Termin Enddatum</th>
</tr>
</thead>
<tbody>
{% for entity in entities %}
<tr>
<td>
{{ entity.repeating_event.summary }}
</td>
<td>
<a href="{{ path('_show', {'slug':entity.event.slug}) }}">{{ entity.event.summary }}</a>
</td>
<td>
{{ entity.event_startdate.format('Y-m-d H:i') }}
</td>
<td>
{% if entity.event_enddate %}
{{ entity.event_enddate.format('Y-m-d H:i') }}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}