{# -*- mode: jinja-html -*- #}
{% extends "base.j2" %}
{% import 'wtf.j2' as wtf %}

{% macro render_field(field, auth_name=None) %}
<tr style="">
    {% if auth_name %}
    <td class="wtf-field"> {{ field.label }}<span style="font-weight:700;"> (compte {{ auth_name }}):</span></td>
    {% else %}
    <td class="wtf-field">{{ field.label }}</td>
    {% endif %}
    <td class="wtf-field">{{ field(**kwargs)|safe }}
        {% if field.errors %}
        <ul class=errors>
            {% for error in field.errors %}
            <li>{{ error }}</li>
            {% endfor %}
        </ul>
        {% endif %}
    </td>
</tr>
{% endmacro %}

{% block app_content %}
<h1>Modification du compte ScoDoc <tt>{{form.user_name.data}}</tt></h1>
<div class="help" style="margin-top: 32px; margin-bottom: 32px;">
    <p>Le mot de passe ScoDoc doit être suffisament complexe.
    Il n'a rien à voir avec celui de votre compte ENT (utilisé pour le service CAS).
    </p>
</div>
<form method="post">
    {{ form.user_name }}
    {{ form.csrf_token }}

    <table class="tf">
        <tbody>
            {{ render_field(form.old_password, size=14, auth_name=auth_username,
            style="padding:1px; margin-left: 1em; margin-top: 4px;") }}
            <tr>
                <td colspan="2">Vous pouvez changer le mot de passe et/ou l'adresse email.</td>
            </tr>
            <tr>
                <td colspan="2">Les champs laissés vides ne seront pas modifiés.</td>
            </tr>
            {{ render_field(form.new_password, size=14,
            style="padding:1px; margin-left: 1em; margin-top: 12px;") }}
            {{ render_field(form.bis_password, size=14,
            style="padding:1px; margin-left: 1em; margin-top: 4px;") }}
            {{ render_field(form.email, size=40,
            style="padding:1px; margin-top: 12px;margin-bottom: 16px; margin-left: 1em;") }}
        </tbody>
    </table>
    <input type="submit" value="Valider">
    <input type="submit" name="cancel" value="Annuler" style="margin-left: 1em;>
    </form>
{% endblock %}