{% extends "orga/base.html" %}
{% load i18n %}
{% load rules %}

{% block title %}{% trans "Dashboard" %}{% endblock %}

{% block content %}
    {% has_perm 'orga.create_events' request.user request.user as can_create_event %}
    {% if can_create_event %}
    <div class="d-flex">
    <a href="{% url "orga:event.create" %}" class="btn btn-success ml-auto">
        <i class="fa fa-plus"></i> {% trans "New event" %}
    </a>
    </div>
    {% endif %}
    {% if current_orga_events %}
    <h2>{% trans "Upcoming events" %}</h2>
    <table class="table">
        <thead>
            <th>{% trans "Name" %}</th>
            <th>{% trans "URL" %}</th>
            <th>{% trans "Date" %}</th>
        </thead>
        <tbody>
            {% for event in current_orga_events %}
            <tr>
                <td>
                    <a href="{{ event.orga_urls.base }}">{{ event.name }}</a>
                </td>
                <td>/{{ event.slug }}</td>
                <td>{{ event.get_date_range_display }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% endif %}
    {% if past_orga_events %}
    <h2>{% trans "Past events" %}</h2>
    <table class="table">
        <thead>
            <th>{% trans "Name" %}</th>
            <th>{% trans "URL" %}</th>
            <th>{% trans "Date" %}</th>
        </thead>
        <tbody>
            {% for event in past_orga_events %}
            <tr>
                <td>
                    <a href="{{ event.orga_urls.base }}">{{ event.name }}</a>
                </td>
                <td>/{{ event.slug }}</td>
                <td>{{ event.get_date_range_display }}</td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
    {% endif %}
{% endblock %}
