Fixed event listing

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI 2012-08-15 18:07:46 +02:00
parent 7a77a4e1ed
commit 111c563409
6 changed files with 44 additions and 17 deletions

View File

@ -34,7 +34,7 @@ class EventController extends Controller
/**
* @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin")
* @Template()
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug"="slug", "startDate"="startDate"}})
* @ParamConverter("event", class="KekRozsakFrontBundle:Event", options={"mapping"={"eventSlug": "slug", "startDate": "startDate"}})
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
*/
public function joinAction(\DateTime $startDate, Event $event)
@ -58,18 +58,25 @@ class EventController extends Controller
}
/**
* @Route("/esemenyek/{date}", name="KekRozsakFrontBundle_eventList")
* @Route("/esemenyek/{date}", name="KekRozsakFrontBundle_eventList", defaults={"date": null})
* @Template()
* @ParamConverter("date", options={"format": "Y-m-d"})
*/
public function listAction(\DateTime $date)
public function listAction($date = null)
{
$realDate = null;
if ($date === null) {
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND (e.startDate >= :day OR (e.startDate <= :day AND e.endDate >= :day))');
$query->setParameter('day', new \DateTime('now'), \Doctrine\DBAL\Types\Type::DATE);
} else {
$realDate = \DateTime::createFromFormat('Y-m-d', $date);
$query = $this->getDoctrine()->getEntityManager()->createQuery('SELECT e FROM KekRozsakFrontBundle:Event e WHERE e.cancelled = FALSE AND ((e.startDate < :day AND e.endDate >= :day) OR e.startDate = :day)');
$query->setParameter('day', $date, \Doctrine\DBAL\Types\Type::DATE);
$query->setParameter('day', $realDate, \Doctrine\DBAL\Types\Type::DATE);
}
$events = $query->getResult();
return array(
'day' => $date,
'day' => $realDate,
'events' => $events,
);
}

View File

@ -399,4 +399,20 @@ class Event
)
);
}
/**
* Check if the event happened before a given date
*
* @param DateTime $date
* @return boolean
*/
public function isPast(\DateTime $date = null)
{
if ($date === null)
{
$date = new \DateTime('now');
}
return ($this->endDate < $date);
}
}

View File

@ -38,7 +38,7 @@
OR (event.startDate <= this day AND evend.endDate >= this day)
#}
<td id="event-calendar-{{ i }}"{% if eventList[i].events|length > 0 %} class="program" rel="{{ path('KekRozsakFrontBundle_eventAjaxList', {date: eventList[i].date|date('Y-m-d'), _format: 'html'}) }}"{% endif %}>
<a href="{{ path('KekRozsakFrontBundle_eventList', { date: eventList[i].date|date('Y-m-d'), _format: 'html'}) }}">{{ eventList[i].date|date('d') }}</a>
<a href="{{ path('KekRozsakFrontBundle_eventList', { date: eventList[i].date|date('Y-m-d')}) }}">{{ eventList[i].date|date('d') }}</a>
</td>
{% if cur is divisibleby(7) %}
</tr>
@ -56,7 +56,7 @@ OR (event.startDate <= this day AND evend.endDate >= this day)
</tr>
</tbody>
</table>
<a href="">További események</a>
<a href="{{ path('KekRozsakFrontBundle_eventList') }}">További események</a>
</div>
</div>
</div>

View File

@ -213,7 +213,7 @@
$('#news-close-button').click(function() {
$('#hirek').html('');
$('#hirek').hide();
$('#content-outline').css('width', '955px');
$('#content-outline').css('width', '960px');
$('#news-button').show();
resizeBoxes();
});

View File

@ -3,7 +3,7 @@
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
{% block title %} - Események - {{ day|date('Y-m-d') }}{% endblock %}
{% block content %}
<h3>Események - {{ day|date('Y-m-d') }}</h3>
<h3>Események{% if day is not null %} - {{ day|date('Y-m-d') }}{% endif %}</h3>
{% if events %}
<ul>
{% for event in events %}
@ -11,6 +11,10 @@
{% endfor %}
</ul>
{% else %}
{% if day is not null %}
<p>Erre a napra nincsenek kiírva események.</p>
{% else %}
<p>Nincsenek kiírva későbbi események.</p>
{% endif %}
{% endif %}
{% endblock content %}

View File

@ -15,7 +15,7 @@
<li>{{ attendee|userdataspan }}</li>
{% endfor %}
</ul>
{% if not event.isAttending(app.user) %}
<a href="{{ path('KekRozsakFrontBundle_eventJoin', { eventDate: event.startDate|date('Y-m-d'), eventSlug: event.slug }) }}">Megyek</a>
{% if not event.isAttending(app.user) and not event.isPast %}
<a href="{{ path('KekRozsakFrontBundle_eventJoin', { startDate: event.startDate|date('Y-m-d'), eventSlug: event.slug }) }}">Megyek</a>
{% endif %}
{% endblock content %}