{% extends "aldryn_events/two_column.html" %}
{% load i18n aldryn_events cms_tags %}

{% block events_content %}
    {# INFO: if configuration is set, show ongoing events first #}
    {% if view.config.app_data.config.show_ongoing_first %}
        {% render_placeholder view.config.placeholder_events_list_top_ongoing %}
        <div class="aldryn-events-list aldryn-events-list-ongoing">
            {% regroup ongoing_objects by start_date as ongoing_objects_grouped %}
            {% for event in ongoing_objects_grouped %}
                <h2>{{ event.start_date|date:"l, j F o" }}</h2>
                {% include "aldryn_events/includes/event.html" with is_ongoing_events="true" %}
            {% empty %}
                <p class="well">{% trans "No items available" %}</p>
            {% endfor %}
        </div>
    {% endif %}

    {# INFO: show upcoming events #}
    {% render_placeholder view.config.placeholder_events_list_top %}
    <div class="aldryn-events-list">
        {% regroup page_obj.object_list|default:object_list by start_date as event_list_grouped %}
        {% for ev_group in event_list_grouped %}
            <h2>{{ ev_group.grouper|date:"l, j F o" }}</h2>
            {% for event in ev_group.list %}
                {% include "aldryn_events/includes/event.html" with is_upcoming_events="true" %}
            {% endfor %}
        {% empty %}
            <p class="well">{% trans "No items available" %}</p>
        {% endfor %}
    </div>
    {% render_placeholder view.config.placeholder_events_list_bottom %}

    <div class="aldryn-events-pagination">
        {% include "aldryn_events/includes/pagination.html" %}
    </div>
{% endblock events_content %}

{% block events_sidebar %}
    {% get_current_language as language %}
    <div class="aldryn-events-calendar">
        {% calendar event_year event_month namespace=view.namespace %}
    </div>
{% endblock events_sidebar %}
