{% extends "misago/admin/generic/list.html" %}
{% load i18n misago_admin_form misago_avatars %}


{% block page-actions %}
<div class="col-auto page-action">
  <a href="{% url 'misago:admin:users:new' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-plus-circle"></span>
    {% trans "New user" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th style="width: 1px;">&nbsp;</th>
<th>{% trans "User" %}</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 150px;">{% trans "Rank" %}</th>
<th style="width: 200px;">{% trans "Registration" %}</th>
<th style="width: 150px;">{% trans "Posts" %}</th>
{% for action in extra_actions %}
  <th>&nbsp;</th>
{% endfor %}
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="pr-0">
  <a href="{{ item.get_absolute_url }}">
    <img src="{{ item|avatar:40 }}" alt="{% trans 'Avatar' %}" width="40" height="40">
  </a>
</td>
<td class="pr-0">
  <div class="small">
    <a href="{% url 'misago:admin:users:edit' pk=item.pk %}" class="item-name">
      {{ item }}
    </a>
  </div>
  <div class="small">
    <a href="mailto:{{ item.email }}">{{ item.email }}</a>
  </div>
</td>
<td class="badges-list">
  {% if item.is_superuser %}
    <span class="badge badge-danger" data-tooltip="top" title="{% trans 'Can use admin control panel and manage other administrators' %}">
      {% trans "Super Admin" %}
    </span>
  {% elif item.is_staff %}
    <span class="badge badge-danger" data-tooltip="top" title="{% trans 'Can use admin control panel' %}">
      {% trans "Admin" %}
    </span>
  {% endif %}
  {% if item.requires_activation_by_admin %}
    <span class="badge badge-primary" data-tooltip="top" title="{% trans 'Requires activation by administrator' %}">
      {% trans "Inactive" %}
    </span>
  {% elif item.requires_activation_by_user %}
    <span class="badge badge-primary" data-tooltip="top" title="{% trans 'Has to activate their account' %}">
      {% trans "Inactive" %}
    </span>
  {% endif %}
  {% if item.is_deleting_account %}
    <span class="badge badge-warning" data-tooltip="top" title="{% trans 'Account scheduled for deletion' %}">
      {% trans "Deleted" %}
    </span>
  {% elif not item.is_active %}
    <span class="badge badge-dark" data-tooltip="top" title="{% trans 'Account disabled' %}">
      {% trans "Disabled" %}
    </span>
  {% endif %}
</td>
<td class="small">
  {{ item.rank }}
</td>
<td class="small">
  <abbr data-timestamp="{{ item.joined_on.isoformat }}" data-format="LL">
    {{ item.joined_on }}
  </abbr>
  <div>
    {% if item.joined_from_ip %}
      {{ item.joined_from_ip }}
    {% else %}
      <i class="text-muted">{% trans "IP removed" %}</i>
    {% endif %}
  </div>
</td>
<td class="small">
  {{ item.posts }}
</td>
{% include "misago/admin/generic/list_extra_actions.html" %}
<td>
  <a href="{% url 'misago:admin:users:edit' pk=item.pk %}" class="btn btn-light btn-sm" data-tooltip="top" title="{% trans 'Edit user' %}">
    {% trans "Edit" %}
  </a>
</td>
{% endblock table-row %}


{% block blankslate %}
<td colspan="{{ 7|add:extra_actions_len }}">
  {% trans "No users matching criteria exist." %}
</td>
{% endblock blankslate %}


{% block filters-modal-body %}
<div class="alert alert-info" role="alert">
  <p>
    {% trans 'You can include wildcard ("*") in username and email search:' %}
  </p>
  <p>
    {% trans '"admin*" will find both "admin" and "administrator".' %}
  </p>
  <p>
    {% trans '"*chan" will match both "chan" and "marichan".' %}
  </p>
  <p class="mb-0">
    {% trans '"*son*" will match "son", "song", "firstson" and "firstsong".' %}
  </p>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.username %}
  </div>
  <div class="col">
    {% form_row filter_form.email %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.rank %}
  </div>
  <div class="col">
    {% form_row filter_form.role %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.profilefields %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_checkbox_row filter_form.is_inactive %}
  </div>
  <div class="col">
    {% form_checkbox_row filter_form.is_disabled %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_checkbox_row filter_form.is_deleting_account %}
  </div>
  <div class="col">
    {% form_checkbox_row filter_form.is_staff %}
  </div>
</div>
{% endblock filters-modal-body %}
