{% extends "admin/base.html" %}
{% comment %}
SPDX-License-Identifier: GPL-3.0-or-later
{% endcomment %}

{% load i18n staticfiles %}

{% block title %}{{ title }} | {{ request.site.name }}{% endblock %}

{% block branding %}
    <strong id="site-name">
        <a href="{{ site_url }}">
            {{ request.site.name }}
        </a>
    </strong>
{% endblock %}

{% block usertools %}
    {% if user.is_authenticated %}
        <div id="user-tools">
            {% block welcome-msg %}
                {% trans 'Welcome,' %}
                <strong>{% firstof user.get_short_name user.get_username %}</strong>.
            {% endblock %}
            {% block userlinks %}
                {% if site_url %}
                    <a href="{{ site_url }}">{% trans 'View site' %}</a> /
                {% endif %}
                {% if available_apps %}
                    {# When in admin site, list all admin pages and documentation #}
                    <span class="dropdown">
                        <a href="{% url 'admin:index' %}">{% trans 'View admin' %}</a>
                        <span class="dropdown-content">
                            {% for app in available_apps %}
                                {% for model in app.models %}
                                    {% if model.admin_url %}
                                        <a href="{{ model.admin_url }}">{{ model.name }}</a>
                                    {% endif %}
                                {% endfor %}
                            {% endfor %}
                            {% if user.is_active and user.is_superuser %}
                                {% url 'django-admindocs-docroot' as docsroot %}
                                {% if docsroot %}
                                    <a href="{{ docsroot }}">{% trans 'Documentation' %}</a>
                                {% endif %}
                            {% endif %}
                         </span>
                    </span> /
                {% elif user.is_staff %}
                    {# When not in admin site, but user is staff then add a link #}
                    <a href="{% url 'admin:index' %}">{% trans 'View admin' %}</a> /
                {% endif %}
                <a href="{% url 'logout' %}">{% trans 'Log out' %}</a>
            {% endblock %}
        </div>
    {% endif %}
{% endblock %}

{% block extrastyle %}
    <link rel="stylesheet" type="text/css" href="{% static "css/admin.css" %}"/>

    {# Favicon #}
    <link rel="apple-touch-icon" sizes="180x180" href="{% static "favicon/apple-touch-icon.png" %}">
    <link rel="icon" type="image/png" sizes="32x32" href="{% static "favicon/favicon-32x32.png" %}">
    <link rel="icon" type="image/png" sizes="16x16" href="{% static "favicon/favicon-16x16.png" %}">
    <link rel="manifest" href="{% static "favicon/site.webmanifest" %}">
    <link rel="mask-icon" href="{% static "favicon/safari-pinned-tab.svg" %}" color="#5bbad5">
    <link rel="shortcut icon" href="{% static "favicon/favicon.ico" %}">
    <meta name="msapplication-TileColor" content="#da532c">
    <meta name="msapplication-config" content="{% static "favicon/browserconfig.xml" %}">
    <meta name="theme-color" content="#ffffff">
{% endblock %}

{% block footer %}
    {% if not is_popup %}
        <div id="footer">
            <form action="{% url 'set_language' %}" method="post">
                {% csrf_token %}
                <select title="language" name="language" onchange="this.form.submit()">
                    {% get_current_language as LANGUAGE_CODE %}
                    {% get_available_languages as LANGUAGES %}
                    {% get_language_info_list for LANGUAGES as languages %}
                    {% for language in languages %}
                        <option value="{{ language.code }}"{% if language.code == LANGUAGE_CODE %} selected{% endif %}>
                            {{ language.name_local }} ({{ language.code }})
                        </option>
                    {% endfor %}
                </select>
                <noscript>
                    <input type="submit">
                </noscript>
                Note Kfet 2018-2020 &mdash; <a href="mailto:tresorerie.bde@lists.crans.org">Nous contactez</a>
            </form>
        </div>
    {% endif %}
{% endblock %}