{% load i18n static sekizai_tags aldryn_events %}

{% block events_calendar %}
    {% if namespace_error %}
        {% if request.user.is_staff or request.user.is_superuser %}
            <div class="events-calendar events-calendar-error">
                <p class="config-errors">{{ namespace_error }}</p>
            </div>
        {% endif %}
    {% else %}
        <div class="events-calendar js-events-calendar"
            data-url="{% fallback_aware_namespace_url 'get-calendar-dates' calendar_tag.namespace %}"
            data-pk="{{ plugin.instance.pk }}"
            data-error="{% trans 'There was a problem accessing the calendar, please try again.'|escapejs %}">

            <h3>{{ calendar_tag.label }}</h3>
            <p class="controls clearfix">
                <a href="#" class="pull-left js-trigger" data-direction="previous">{% trans "Previous month" %}</a>
                <a href="{% fallback_aware_namespace_url 'events_list' calendar_tag.namespace %}">{% trans "Today" %}</a>
                <a href="#" class="pull-right js-trigger" data-direction="next">{% trans "Next month" %}</a>
            </p>
            {% include "aldryn_events/includes/calendar_table.html" %}
        </div>
    {% endif %}
{% endblock %}

{% addtoblock "js" %}<script src="{% static 'js/addons/cl.events.js' %}"></script>{% endaddtoblock %}
