{% extends "otree/BaseAdmin.html" %}
{% load i18n admin_static otree_tags floppyforms %}
{% block title %}Admin Login{% endblock %}

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

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

    <p class="text-danger">{% ensure_superuser_exists %}</p>

    <div id="content-main">
        <form action="{{ app_path }}" method="post"
              id="login-form">{% csrf_token %}
            {% form form using %}
                {% formconfig row using "floppyforms/rows/bootstrap.html" %}
                <div class="form-row">
                    {% formfield form.username %}
                </div>
                <div class="form-row">
                    {% formfield form.password %}
                    <input type="hidden" name="next" value="{{ next }}"/>
                </div>
                <div class="form-row">
                    The password is defined in your <code>settings.py</code>
                    file.

                </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="submit-row">
                    <button type="submit"
                            class="btn btn-default">{% trans 'Log in' %}</button>
                </div>
            {% endform %}
        </form>

        <script type="text/javascript">
            document.getElementById('id_username').focus()
        </script>
    </div>
{% endblock %}
