{% extends "base.html" %}
{% load logentries %}
{% load user_extras %}
{% load event_extras %}
{% load i18n %}
{% load static %}


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

{% block javascript %}
    <script type="text/javascript" src="{% static "ephios/js/consequences.js" %}"></script>
{% endblock %}

{% block content %}
    <h1 class="page-header">
        {% trans "Welcome to ephios!" %}
    </h1>

    {% with request.user|confirmed_participations as confirmed_participations %}
        {% if confirmed_participations|length > 0 %}
            <div class="card mb-3">
                <div class="card-body">
                    <h5 class="card-title mb-0">{% trans "Your upcoming events" %}</h5>
                </div>
                <ul class="list-group list-group-flush">
                    {% for participation in confirmed_participations %}
                        <li class="list-group-item flex-column">
                            <div class="d-flex w-100 justify-content-between align-items-center">
                                <span>{{ participation.shift.event.title }} ({{ participation.get_date_display }}, {{participation.get_time_display }})</span>
                                <a class="btn btn-outline-primary btn-sm"
                                   href="{{ participation.shift.get_absolute_url }}"><span
                                        class="fa fa-eye"></span> <span
                                        class="d-none d-md-inline">{% translate "View" %}</span></a>
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endif %}
    {% endwith %}

    {% with request.user|shifts_needing_disposition as shifts %}
        {% if shifts|length > 0 %}
            <div class="card mb-3">
                <div class="card-body">
                    <h5 class="card-title mb-0">{% trans "Events with requested participations" %}</h5>
                </div>
                <ul class="list-group list-group-flush">
                    {% for shift in shifts %}
                        <li class="list-group-item flex-column">
                            <div class="d-flex w-100 justify-content-between align-items-center">
                                <span class="">{{ shift.event.title }} ({{ shift.get_datetime_display }})</span>
                                <div>
                                    <a class="btn btn-outline-primary btn-sm"
                                       href="{% url "core:event_detail" shift.event.pk shift.event.get_canonical_slug %}"><span
                                            class="fa fa-eye"></span> <span
                                            class="d-none d-md-inline">{% translate "View" %}</span></a>
                                    <a class="btn btn-outline-primary btn-sm"
                                       href="{% url "core:shift_disposition" shift.pk %}"><span
                                            class="fas fa-hand-point-right"></span> <span
                                            class="d-none d-md-inline">{% translate "Disposition" %}</span></a>
                                </div>
                            </div>
                        </li>
                    {% endfor %}
                </ul>
            </div>
        {% endif %}
    {% endwith %}

    {% include "core/fragments/approve_consequences.html" %}
    {% include "core/fragments/pending_consequences.html" %}

    {% with logentries=request.user|visible_logentries %}
        {% if logentries %}
            <div class="card mb-3">
                <div class="card-body">
                    <h5 class="card-title mb-0">
                        {% trans "Edit history" %}
                        <a class="btn btn-outline-primary btn-sm float-end" href="{% url "core:log" %}">
                            <span class="fas fa-eye"></span>
                            <span class="d-none d-md-inline">{% translate "View everything" %}</span>
                        </a>
                    </h5>
                </div>
                {% include 'modellogging/logentry_grouped_list.html' with logentries=logentries %}
            </div>
        {% endif %}
    {% endwith %}

{% endblock %}
