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

{% block extrahead %}
    {{ block.super }}
    <script type="text/javascript" src="{% url 'admin:jsi18n' %}"></script>
{% endblock %}

{% block extrastyle %}
    {{ block.super }}
    <link rel="stylesheet" type="text/css" href="{% if LANGUAGE_BIDI %}{% static "admin/css/forms_rtl.css" %}{% else %}{% static "admin/css/forms.css" %}{% endif %}">
{% endblock %}

{% if not is_popup %}
    {% block breadcrumbs %}
        <div class="breadcrumbs{% if LANGUAGE_BIDI %} rbc{% else %} lbc{% endif %}">
            <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
            &rsaquo; {{ opts.app_config.verbose_name }}
            &rsaquo; <a href="{% url opts|admin_urlname:'changelist' %}">{{ opts.verbose_name_plural|capfirst }}</a>
            &rsaquo; <a href="{% url opts|admin_urlname:'change' original.pk|admin_urlquote %}">{{ original|truncatewords:"18" }}</a>
            &rsaquo; {% trans 'Change password' %}
        </div>
    {% endblock %}
{% endif %}

{% block content %}
    <div class="content">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-header {{ direction.panel }}">
                        <div class="title">
                            {% blocktrans with username=original %}
                                Enter a new password for the user
                                <strong>{{ username }}</strong>.
                            {% endblocktrans %}
                        </div>
                    </div>
                    <div class="card-body">
                        <form action="{{ form_url }}" method="post" id="{{ opts.model_name }}_form">
                            {% csrf_token %}

                            {% block form_top %}{% endblock %}
                            <input type="text" name="username" value="{{ original.get_username }}" style="display: none">

                            <div class="col-md-8 {{ direction.panel }}">
                                {% if is_popup %}<input type="hidden" name="_popup" value="1">{% endif %}

                                <div class="form-group">
                                    {{ form.password1.errors }}
                                    {{ form.password1.label_tag }} {{ form.password1 }}
                                    {% if form.password1.help_text %}
                                        <div class="help">{{ form.password1.help_text|safe }}</div>
                                    {% endif %}
                                </div>

                                <div class="form-group">
                                    {{ form.password2.errors }}
                                    {{ form.password2.label_tag }} {{ form.password2 }}
                                    {% if form.password2.help_text %}
                                        <div class="help">{{ form.password2.help_text|safe }}</div>
                                    {% endif %}
                                </div>
                            </div>

                            <div class="card">
                                <div class="card-body">
                                    <button type="submit" class="btn btn-sm btn-primary">
                                        {% trans 'Change my password' %}
                                    </button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}

{% block extrascript %}
    <script type="application/javascript">
        {% if form.errors %}
            {% if form.errors.items|length == 1 %}
                notification.danger("<p class='{{ direction.panel }}'>" + "{% trans "Please correct the error below." %}" + "</p>", 'top', '{{ direction.notify }}');
            {% else %}
                notification.danger("<p class='{{ direction.panel }}'>" + "{% trans "Please correct the errors below." %}" + "</p>", 'top', '{{ direction.notify }}');
            {% endif %}
        {% endif %}
    </script>
{% endblock %}
