{% extends "base.html" %} {% block title %}{{ title }}{% endblock %} {% block content %} {% include '_quota_warning.html' %}
{# ── Account Status card (edit mode only, not own account) ── #} {% if user and user.id != current_user.id %}
Account Status: {{ 'Active' if user.active else 'Disabled' }}
{% if user.active %} Disabling this account will immediately prevent the user from logging in. {% else %} This account is currently disabled — the user cannot log in. {% endif %}
{% endif %} {# ── Edit form ── #}

{{ title }}

{{ form.hidden_tag() }}
{{ form.username.label(class="form-label") }} {{ form.username(class="form-control") }} {% if form.username.errors %}
{% for error in form.username.errors %}{{ error }}{% endfor %}
{% endif %}
{{ form.full_name.label(class="form-label") }} {{ form.full_name(class="form-control", placeholder="e.g. Jane Smith") }} {% if form.full_name.errors %}
{% for error in form.full_name.errors %}{{ error }}{% endfor %}
{% endif %}
{{ form.email.label(class="form-label") }} {{ form.email(class="form-control") }} {% if form.email.errors %}
{% for error in form.email.errors %}{{ error }}{% endfor %}
{% endif %}
{# MT-15 — an External Inspector is invited by email and chooses their own password, so the admin never sets one. The JS at the foot of this page swaps these two blocks when the role changes; the server decides independently of the JS. #}
This account will be invited by email. External inspectors work outside the business, so we do not set a password for them. On save, an invitation is sent to the email address above with a link to choose their own password. The link is valid for 72 hours.
{{ form.password.label(class="form-label") }} {{ form.password(class="form-control", placeholder="Leave blank to keep current" if user else "") }} {% if form.password.errors %}
{% for error in form.password.errors %}{{ error }}{% endfor %}
{% endif %}
{{ form.confirm_password.label(class="form-label") }} {{ form.confirm_password(class="form-control") }} {% if form.confirm_password.errors %}
{% for error in form.confirm_password.errors %}{{ error }}{% endfor %}
{% endif %}
{{ form.role.label(class="form-label") }} {% if director_editing %} {# Directors can see the current role but cannot change it #}
{{ (user.role if user else 'Inspector').replace('_', ' ')|title }}
Role assignment requires Administrator access.
{% else %} {{ form.role(class="form-select") }} {% endif %}
Cancel
{% endblock %}