{% extends "dictionary/user/preferences/index.html" %}
{% load widget_tweaks i18n filters %}
{% block title %}{% trans "password change" context "titleblock" %}{% endblock %}

{% block content_preferences %}
    {% if form.errors %}
        <div class="alert-danger p-3 my-3 rounded" role="alert">
            <span>{% trans "please try again after checking specified errors." %}</span>
        </div>
    {% endif %}

    <form method="post">
        {{ form.non_field_erros }}
        {% with WIDGET_ERROR_CLASS='is-invalid' %}
            <div class="form-group">
                <label class="mr-2" for="pref_old_password"><strong>{{ form.old_password.label|i18n_lower }}</strong></label>
                {% render_field form.old_password class="form-control" id="pref_old_password" %}
                {% for error in form.old_password.errors %}
                    <small class="form-text text-danger">{{ error|i18n_lower }}</small>
                {% endfor %}
            </div>

            <div class="form-group">
                <label class="mr-2" for="pref_new_password1"><strong>{{ form.new_password1.label|i18n_lower }}</strong></label>
                {% render_field form.new_password1 class="form-control" id="pref_new_password1" %}
                {% for error in form.new_password1.errors %}
                    <small class="form-text text-danger">{{ error|i18n_lower }}</small>
                {% endfor %}
                <small class="form-text text-muted password-help">{{ form.new_password1.help_text|i18n_lower|safe }}</small>
            </div>

            <div class="form-group">
                <label class="mr-2" for="pref_new_password2"><strong>{{ form.new_password2.label|i18n_lower }}</strong></label>
                {% render_field form.new_password2 class="form-control" id="pref_new_password2" %}
                {% for error in form.new_password2.errors %}
                    <small class="form-text text-danger">{{ error|i18n_lower }}</small>
                {% endfor %}
            </div>
        {% endwith %}

        {% csrf_token %}
        <button type="submit" class="btn btn-django stretch">{% trans "change password" %}</button>
    </form>
{% endblock %}
