{% extends "admin/base.html" %}
{% load i18n %}

{% block nav-global %}{% endblock %}
{% block main %}

  <section class="section">
    <div class="container" style="max-width:480px">

      <h1 class="title">{{request.settings.site_title}}</h1>
      {% if form.errors and not form.non_field_errors %}
        <div class="notification is-error">
          <button class="delete"></button>
          {% if form.errors.items|length == 1 %}{% trans "Please correct the error below." %}{% else %}{% trans "Please correct the errors below." %}{% endif %}
        </div>
      {% endif %}

      {% if form.non_field_errors %}
        {% for error in form.non_field_errors %}
          <div class="notification is-danger is-light">
            <button class="delete"></button>
            {{ error }}
          </div>
        {% endfor %}
      {% endif %}

      <div id="content-main">

        {% if user.is_authenticated %}
          <p class="errornote">
            {% 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 %}

        <form action="{{ app_path }}" method="post" id="login-form">{% csrf_token %}
          <div class="field">
            {{ form.username.errors }}
            <label class="label" for="id_username">{{form.username.label}}:</label>
            <input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username" class="input">
          </div>
          <div class="field">
            {{ form.password.errors }}
            <label class="label" for="id_password">{{form.password.label}}:</label>
            <input type="password" name="password" autocomplete="current-password" required="" id="id_password" class="input">
            <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="field">
            <div class="buttons">
              <input type="submit" value="{% trans 'Log in' %}" class="button is-primary">
              {% if site_url %}
                <a href="{{site_url}}" class="button">返回首页</a>
              {% endif %}
            </div>
          </div>
        </form>

      </div>
    </div>
  </section>
{% endblock %}
