Skip to content

Commit

Permalink
Widget: also show ongoing event
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Sep 12, 2023
1 parent 8866838 commit 2151725
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
3 changes: 1 addition & 2 deletions app/Resources/views/admin/event/_partial/card.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{% set ongoing = ongoing ?? false %}
{% set from_admin = from_admin ?? false %}

<div class="card small {% if from_admin %}blue-grey darken-1{% endif %}">
Expand All @@ -15,7 +14,7 @@
{% if event.kind %}
<span class="badge teal white-text">{{ event.kind }}</span>
{% endif %}
{% if ongoing %}
{% if event.end and event.isOngoing %}
<span class="badge deep-purple white-text">En cours</span>
{% endif %}
</p>
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/views/admin/event/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="row">
{% for event in eventsOngoing %}
<div class="col m12 l6">
{% include "admin/event/_partial/card.html.twig" with { event: event, ongoing: true, from_admin: true } %}
{% include "admin/event/_partial/card.html.twig" with { event: event, from_admin: true } %}
</div>
{% endfor %}
</div>
Expand Down
7 changes: 6 additions & 1 deletion app/Resources/views/event/_partial/widget.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
<span>-</span>
<strong>{% if links %}<a href="{{ path('event_detail', { 'id': event.id }) }}" target="_blank">{% endif %}{{ event.title }}{% if links %}</a>{% endif %}</strong>
{{ event.date | date_fr_full_with_time }}
{% if event.end %}<i>({{ event.duration }})</i>{% endif %}
{% if event.end %}
<i>({{ event.duration }})</i>
{% if event.isOngoing %}
<span>[en cours]</span>
{% endif %}
{% endif %}
{# {% if not eventKind %}[{{ event.kind }}] {% endif %} #}
</li>
{% endfor %}
Expand Down
2 changes: 1 addition & 1 deletion app/Resources/views/event/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="row">
{% for event in eventsOngoing %}
<div class="col m12 l6">
{% include "admin/event/_partial/card.html.twig" with { event: event, ongoing: true } %}
{% include "admin/event/_partial/card.html.twig" with { event: event } %}
</div>
{% endfor %}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/AppBundle/Controller/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function widgetAction(Request $request)
$eventKind = $em->getRepository('AppBundle:EventKind')->find($filter_event_kind_id);
}

$events = $em->getRepository('AppBundle:Event')->findFutures($eventKind, $eventDateMax, $filter_limit);
$events = $em->getRepository('AppBundle:Event')->findFutureOrOngoing($eventKind, $eventDateMax, $filter_limit);

return $this->render('event/_partial/widget.html.twig', [
'events' => $events,
Expand Down
9 changes: 9 additions & 0 deletions src/AppBundle/Entity/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,15 @@ public function isStartBeforeEnd()
return true;
}

/**
* @return boolean
*/
public function getIsOngoing()
{
$now = new \DateTime('now');
return ($this->date < $now) && $this->end && ($this->end > $now);
}

/**
* Set description
*
Expand Down

0 comments on commit 2151725

Please sign in to comment.