{% extends "html/settings/base.html" %}

{% block title %}{{ gettext('Users') }}{% endblock %}
{% block page_id %}user-management-page{% endblock %}

{% block settings_main %}
    <h1>{{ gettext('User Management') }}</h1>
    <a href="/adduser" class="boldusercontrol">{{ gettext('Add User') }}</a>
    {% if reset %}
    <p>{{ gettext('The password for the user %(u)s has been reset to <strong>%(p)s</strong>', u=reset[0], p=reset[1]) }}</p>
    {% endif %}
    <table>
      <tr>
        <th>{{ gettext('User') }}</th>
        <th>{{ gettext('Password') }}</th>
        <th>{{ gettext('Suspension') }}</th>
        <th>{{ gettext('Admin') }}</th>
        <th>{{ gettext('Delete') }}</th>
      </tr>
      {% for u in users %}
      {% if u.username() != 'admin' %}
      <tr>
         <td><a href="/home/{{ u }}/">{{ u }}</a></td>
         <td>
            {% if not u.is_external() %}
            <a href="{{ url_for('.users', reset=u.username()) }}">{{ gettext('Reset') }}</a>
            {% endif %}
         </td>
         <td><a href="{{ url_for('.suspend_user', user=u.username()) }}">{% if u.is_suspended() %}{{ gettext('Unsuspend') }}{% else %}{{ gettext('Suspend') }}{% endif %}</a></td>
         <td><a href="{{ url_for('.toggle_admin', user=u.username()) }}">{% if u.is_admin() %}{{ gettext('Revoke') }}{% else %}{{ gettext('Grant') }}{% endif %}</a> </td>
         <td><a href="{{ url_for('.del_user', user=u.username()) }} ">{{ gettext('Delete') }}</a></td>
      </tr>
      {% endif %}
      {% endfor %}
    </table>
{% endblock %}
