Fixed event listing
Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
parent
7a77a4e1ed
commit
111c563409
@ -34,7 +34,7 @@ class EventController extends Controller
|
|||||||
/**
|
/**
|
||||||
* @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin")
|
* @Route("/esemeny/{startDate}/{eventSlug}/csatlakozas", name="KekRozsakFrontBundle_eventJoin")
|
||||||
* @Template()
|
* @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"})
|
* @ParamConverter("startDate", class="DateTime", options={"format"="Y-m-d"})
|
||||||
*/
|
*/
|
||||||
public function joinAction(\DateTime $startDate, Event $event)
|
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()
|
* @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 = $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();
|
$events = $query->getResult();
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'day' => $date,
|
'day' => $realDate,
|
||||||
'events' => $events,
|
'events' => $events,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
OR (event.startDate <= this day AND evend.endDate >= this day)
|
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 %}>
|
<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>
|
</td>
|
||||||
{% if cur is divisibleby(7) %}
|
{% if cur is divisibleby(7) %}
|
||||||
</tr>
|
</tr>
|
||||||
@ -56,7 +56,7 @@ OR (event.startDate <= this day AND evend.endDate >= this day)
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<a href="">További események</a>
|
<a href="{{ path('KekRozsakFrontBundle_eventList') }}">További események</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -213,7 +213,7 @@
|
|||||||
$('#news-close-button').click(function() {
|
$('#news-close-button').click(function() {
|
||||||
$('#hirek').html('');
|
$('#hirek').html('');
|
||||||
$('#hirek').hide();
|
$('#hirek').hide();
|
||||||
$('#content-outline').css('width', '955px');
|
$('#content-outline').css('width', '960px');
|
||||||
$('#news-button').show();
|
$('#news-button').show();
|
||||||
resizeBoxes();
|
resizeBoxes();
|
||||||
});
|
});
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
|
{% extends 'KekRozsakFrontBundle:Default:main_template.html.twig' %}
|
||||||
{% block title %} - Események - {{ day|date('Y-m-d') }}{% endblock %}
|
{% block title %} - Események - {{ day|date('Y-m-d') }}{% endblock %}
|
||||||
{% block content %}
|
{% 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 %}
|
{% if events %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for event in events %}
|
{% for event in events %}
|
||||||
@ -11,6 +11,10 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
{% if day is not null %}
|
||||||
<p>Erre a napra nincsenek kiírva események.</p>
|
<p>Erre a napra nincsenek kiírva események.</p>
|
||||||
|
{% else %}
|
||||||
|
<p>Nincsenek kiírva későbbi események.</p>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<li>{{ attendee|userdataspan }}</li>
|
<li>{{ attendee|userdataspan }}</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% if not event.isAttending(app.user) %}
|
{% if not event.isAttending(app.user) and not event.isPast %}
|
||||||
<a href="{{ path('KekRozsakFrontBundle_eventJoin', { eventDate: event.startDate|date('Y-m-d'), eventSlug: event.slug }) }}">Megyek</a>
|
<a href="{{ path('KekRozsakFrontBundle_eventJoin', { startDate: event.startDate|date('Y-m-d'), eventSlug: event.slug }) }}">Megyek</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock content %}
|
{% endblock content %}
|
||||||
|
Loading…
Reference in New Issue
Block a user