{% extends "admin/base_site.html" %}

<!-- LOADING -->
{% load i18n grp_tags %}

<!-- BODYCLASS -->
{% block bodyclass %}grp-login{% endblock %}

<!-- EXTRAHEAD-->
{% block extrahead %}
    {{ block.super }}
    <script type="text/javascript">
        (function($) {
            $(window).load(function(){ $('#id_username').focus(); });
        })(grp.jQuery);
    </script>
{% endblock %}

<!-- CONTENT -->
{% block content %}
    <div class="g-d-c g-d-10 g-centered">
        <form action="{{ app_path }}" method="post">{% csrf_token %}
            <fieldset class="grp-module grp-module-login">
                <h1>
                    <span class="grp-admin-title">{% if grappelli_admin_title %}{{ grappelli_admin_title }}{% else %}{% get_admin_title %}{% endif %}</span>
                    <span class="grp-current-page">{% trans "Login" %}</span>
                </h1>
                <div class="grp-module">

                    {% if form.errors and not form.non_field_errors and not form.this_is_the_login_form.errors %}
                        <div class="grp-row grp-error-row">
                            <p class="errornote">{% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}</p>
                        </div>
                    {% endif %}
                    {% if form.non_field_errors or form.this_is_the_login_form.errors %}
                        <div class="grp-row grp-error-row">
                            {% for error in form.non_field_errors|add:form.this_is_the_login_form.errors %}
                                <p class="errornote">{{ error }}</p>
                            {% endfor %}
                        </div>
                    {% endif %}
                    {% if error_message %}
                        <div class="grp-row grp-error-row">
                            <p class="errornote">{{ error_message }}</p>
                        </div>
                    {% endif %}

                    <div class="grp-row{% if form.username.errors %} grp-errors{% endif %}">
                        <label for="id_username" class="required">{{ form.username.label }}:</label>
                        <input type="text" name="username" id="id_username" />
                        {% if not form.this_is_the_login_form.errors %}{{ form.username.errors }}{% endif %}
                    </div>
                    <div class="grp-row grp-connected{% if form.password.errors %} grp-errors{% endif %}">
                        <label for="id_password" class="required">{% trans 'Password:' %}</label>
                        <input type="password" name="password" id="id_password" />
                        <input type="hidden" name="this_is_the_login_form" value="1" />
                        <input type="hidden" name="next" value="{{ next }}" />
                        {% if not form.this_is_the_login_form.errors %}{{ form.password.errors }}{% endif %}
                        {% url 'admin_password_reset' as password_reset_url %}
                    </div>
                    {% if password_reset_url %}
                        <div class="grp-row">
                            <p class="grp-description" style="font-size: 11px; line-height: 13px; margin-top: 2px;"><a href="{{ password_reset_url }}">{% trans 'Forgotten your password or username?' %}</a></p>
                        </div>
                    {% endif %}
                </div>
            </fieldset>
            <div class="grp-module grp-submit-row">
                <ul>
                    <li><input type="submit" class="grp-button grp-default" value="{% trans 'Log in' %}" /></li>
                </ul>
            </div>
        </form>
    </div>
{% endblock %}
