{% extends "base.html" %}
{% block title %}Edit User{% endblock %}
{% block content %}
<div class="container mt-4">
    <h1>Edit User: {{ user.username }}</h1>
    <form method="POST">
        {{ form.hidden_tag() }}
        <div class="mb-3">
            {{ form.username.label(class="form-label") }}
            {{ form.username(class="form-control") }}
            {% for error in form.username.errors %}
                <span class="text-danger">{{ error }}</span>
            {% endfor %}
        </div>
        <div class="mb-3">
            {{ form.email.label(class="form-label") }}
            {{ form.email(class="form-control") }}
            {% for error in form.email.errors %}
                <span class="text-danger">{{ error }}</span>
            {% endfor %}
        </div>
        <div class="mb-3">
            {{ form.is_admin.label(class="form-check-label") }}
            {{ form.is_admin(class="form-check-input") }}
            {% for error in form.is_admin.errors %}
                <span class="text-danger">{{ error }}</span>
            {% endfor %}
        </div>
        <div class="mb-3">
            {{ form.force_password_change.label(class="form-check-label") }}
            {{ form.force_password_change(class="form-check-input") }}
            {% for error in form.force_password_change.errors %}
                <span class="text-danger">{{ error }}</span>
            {% endfor %}
        </div>
        <div class="mb-3">
            {{ form.reset_password.label(class="form-label") }}
            {{ form.reset_password(class="form-control") }}
            <small class="form-text text-muted">Leave blank to keep the current password.</small>
            {% for error in form.reset_password.errors %}
                <span class="text-danger">{{ error }}</span>
            {% endfor %}
        </div>
        <div class="mb-3">
            {{ form.confirm_reset_password.label(class="form-label") }}
            {{ form.confirm_reset_password(class="form-control") }}
            {% for error in form.confirm_reset_password.errors %}
                <span class="text-danger">{{ error }}</span>
            {% endfor %}
        </div>
        {{ form.submit(class="btn btn-primary") }}
        <a href="{{ url_for('gallery.admin_users') }}" class="btn btn-secondary">Cancel</a>
    </form>
</div>
{% endblock %}