{% extends "admin/base_login.html" %}
{% load i18n static %}

{% block content %}
    {% if form.errors and not form.non_field_errors %}
        <p class="alert alert-danger">
            {% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}
                {% trans "Please correct the errors below." %}{% endif %}
        </p>
    {% endif %}

    {% if form.non_field_errors %}
        {% for error in form.non_field_errors %}
            <p class="alert alert-danger">
                {{ error }}
            </p>
        {% endfor %}
    {% endif %}


    <form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
        <div class="form-group has-feedback">
            <input type="text" id="id_username" name="username" class="form-control" placeholder="Username" autocomplete="off" autofocus="autofocus">
            <span class="glyphicon glyphicon-user form-control-feedback"></span>
            {{ form.username.errors }}
        </div>
        <div class="form-group has-feedback">
            <input type="password" id="id_password" name="password" class="form-control"
                   placeholder="Password">
            <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            {{ form.password.errors }}
            <input type="hidden" name="next" value="{{ next }}"/>
        </div>
        {% url 'admin_password_reset' as password_reset_url %}
        {% if password_reset_url %}
            <div class="password-reset-link">
                <a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a>
            </div>
        {% endif %}
        <div class="row">
            <!-- /.col -->
            <div class="col-xs-4">
                <button type="submit"
                        class="btn btn-primary btn-block btn-flat">{% trans 'Log In' %}</button>
            </div>
            <!-- /.col -->
        </div>
    </form>


    {% if user.is_authenticated %}
        <p class="alert alert-danger">
            {% blocktrans trimmed %}
                You are authenticated as {{ username }}, but are not authorized to
                access this page. Would you like to login to a different account?
            {% endblocktrans %}
        </p>
    {% endif %}

{% endblock %}
