{% load i18n static %}

{% include "_head.html" %}

<section id="menu">
    <div class="logo">
        <img src="{% static 'images/reymota-logo.svg' %}" alt="">
        <h2>Finanzas</h2>
    </div>
</section>

<section id="interface">

    <div class="board">
        <h2 class="titulo-login">Entrar en Finanzas</h2>

        {% if form.errors and not form.non_field_errors %}
            <p class="errornote">
            {% blocktranslate count counter=form.errors.items|length %}Please correct the error below.{% plural %}Please correct the errors below.{% endblocktranslate %}
            </p>
        {% endif %}

        {% if form.non_field_errors %}
            {% for error in form.non_field_errors %}
                <p class="errornote">
                    {{ error }}
                </p>
            {% endfor %}
        {% endif %}
        
        <div class="formulario">
            {% if user.is_authenticated %}
            <p class="errornote">
            {% blocktranslate trimmed %}
                Has entrado como {{ username }}, pero no tienes autorización para ver esta
                página. Quizá quieras entrar con un usuario diferente
            {% endblocktranslate %}
            </p>
            {% endif %}

            <form class="login-form" action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
                <div class="usuario-login">
                    <div class="usuario">
                        {{ form.username.errors }}
                        {{ form.username.label_tag }}
                    </div>                            
                    <div class="input-usuario">
                        {{ form.username }}
                    </div>
                </div>

                <div class="password-login">
                    <div class="password">
                        {{ form.password.errors }}
                        {{ form.password.label_tag }}
                    </div>
                    <div class="input-password">
                        {{ form.password }}
                        <input type="hidden" name="next" value="{{ next }}">
                    </div>
                </div>

                {% url 'admin_password_reset' as password_reset_url %}
                {% if password_reset_url %}
                <div class="password-reset-link">
                    <a href="{{ password_reset_url }}">{% translate 'Forgotten your password or username?' %}</a>
                </div>
                {% endif %}

                <div class="text-center">
                    <input type="submit" class="btn btn-primary" value="{% translate 'Log in' %}">
                </div>
            </form>
        </div>
    </div>
</section>
{% include "_footer.html" %}
