{% extends "pretixcontrol/event/base.html" %}
{% load i18n %}
{% load eventurl %}
{% load staticfiles %}
{% block title %}{{ request.event.name }}{% endblock %}
{% block content %}
    <form action="{% eventurl request.event "presale:event.auth" %}" method="post" target="_blank">
        <h1>
            {{ request.event.name }}
            {% if has_domain and not request.event.live %}
                <input type="hidden" value="{{ new_session }}" name="session">
                <button type="submit" class="btn btn-default btn-sm">
                    {% trans "Go to shop" %}
                </button>
            {% else %}
                <a href="{% eventurl request.event "presale:event.index" %}" class="btn btn-default btn-sm" target="_blank">
                    {% trans "Go to shop" %}
                </a>
            {% endif %}
        </h1>
    </form>

    {% if actions|length > 0 %}
        <div class="panel panel-danger">
            <div class="panel-heading">
                <h3 class="panel-title">
                    {% trans "Your attention is required to resolve the following issues" %}
                </h3>
            </div>
            <ul class="list-group">
                {% for action in actions %}
                    <li class="list-group-item logentry">
                        <p>
                            <a href="{% url "control:event.requiredaction.discard" event=request.event.slug organizer=request.event.organizer.slug id=action.id %}"
                                    class="btn btn-default btn-xs pull-right">
                                {% trans "Hide message" %}
                            </a>
                            <small><span class="fa fa-clock-o"></span> {{ action.datetime|date:"SHORT_DATETIME_FORMAT" }}</small>
                        </p>
                        {{ action.display|safe }}
                    </li>
                {% endfor %}
            </ul>
            <div class="panel-footer">
                <a href="{% url "control:event.requiredactions" event=request.event.slug organizer=request.event.organizer.slug %}">
                    {% trans "Show more" %}
                </a>
            </div>
        </div>
    {% endif %}

    <div class="row dashboard">
        {% for w in widgets %}
            <div class="widget-container widget-{{ w.display_size|default:"small" }}">
                {% if w.url %}{# backwards compatibility #}
                    <a href="{{ w.url }}" class="widget">
                        {{ w.content|safe }}
                    </a>
                {% elif w.link %}
                    <a href="{{ w.link }}" class="widget">
                        {{ w.content|safe }}
                    </a>
                {% else %}
                    <div class="widget">
                        {{ w.content|safe }}
                    </div>
                {% endif %}
            </div>
        {% endfor %}
    </div>

    <p>&nbsp;</p>
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">
                {% trans "Event logs" %}
            </h3>
        </div>
        <ul class="list-group">
            {% for log in logs %}
                <li class="list-group-item logentry">
                    <div class="row">
                        <div class="col-lg-2 col-sm-6 col-xs-12">
                            <span class="fa fa-clock-o"></span> {{ log.datetime|date:"SHORT_DATETIME_FORMAT" }}
                        </div>
                        <div class="col-lg-2 col-sm-6 col-xs-12">
                            {% if log.user %}
                                {% if log.user.is_superuser %}
                                    <span class="fa fa-id-card fa-danger fa-fw"
                                            data-toggle="tooltip"
                                            title="{% trans "This change was performed by a pretix administrator." %}">
                                </span>
                                {% else %}
                                    <span class="fa fa-user fa-fw"></span>
                                {% endif %}
                                {{ log.user.get_full_name }}
                            {% endif %}
                        </div>
                        <div class="col-lg-2 col-sm-12 col-xs-12">
                            {% if log.display_object %}
                                <span class="fa fa-flag"></span> {{ log.display_object|safe }}
                            {% endif %}
                        </div>
                        <div class="col-lg-6 col-sm-12 col-xs-12">
                            {{ log.display }}
                        </div>
                    </div>
                </li>
            {% endfor %}
        </ul>
        <div class="panel-footer">
            <a href="{% url "control:event.log" event=request.event.slug organizer=request.event.organizer.slug %}">
                {% trans "Show more logs" %}
            </a>
        </div>
    </div>

{% endblock %}
