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

{% 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 %}

{% block breadcrumbs %}
    <div class="breadcrumbs{% if LANGUAGE_BIDI %} rbc{% else %} lbc{% endif %}">
        <a href="{% url 'admin:index' %}">{% trans 'Home' %}</a>
        &rsaquo; {% trans 'Password change' %}
    </div>
{% endblock %}

{% block title %}{{ title }}{% endblock %}
{#{% block content_title %}<h1>{{ title }}</h1>{% endblock %}#}

{% 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">
                            {% trans "Please enter your old password, for security's sake, and then enter your new password twice so we can verify you typed it in correctly." %}
                        </div>
                    </div>
                    <div class="card-body">
                        <form method="post">
                            {% csrf_token %}

                            <div class="col-md-8 {{ direction.panel }}">
                                <div class="form-group">
                                    {{ form.old_password.errors }}
                                    {{ form.old_password.label_tag }} {{ form.old_password }}
                                </div>

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

                                <div class="form-group">
                                    {{ form.new_password2.errors }}
                                    {{ form.new_password2.label_tag }} {{ form.new_password2 }}
                                    {% if form.new_password2.help_text %}
                                        <div class="help">{{ form.new_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 %}
