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


{% block title %}
{% trans "Ban users" context "admin ban users form" %} | {{ active_link.name }} | {{ block.super }}
{% endblock title %}


{% block form-header %}
{% trans "Ban selected users" context "admin ban users form" %}
{% endblock %}


{% block form-body %}
<input type="hidden" name="action" value="ban">
{% for user in users %}
  <input type="hidden" name="selected_items" value="{{ user.pk }}">
{% endfor %}
<div class="form-fieldset pt-0">
  <fieldset>
    <legend>{% trans "Users" context "admin ban users form" %}</legend>
    <div class="card card-admin-table">
      <table class="table">
        <thead>
          <tr>
            <th style="width: 1px;">&nbsp;</th>
            <th>{% trans "User" context "admin ban users list" %}</th>
            <th style="width: 50%;">{% trans "E-mail" context "admin ban users list" %}</th>
            <th style="width: 200px;">{% trans "IP address" context "admin ban users list" %}</th>
          </tr>
        </thead>
        <tbody>
        {% for user in users %}
          <tr>
            <td class="pr-0">
              <a href="{{ user.get_absolute_url }}">
                <img src="{{ user|avatar:24 }}" alt="{% trans 'Avatar' %}" width="24" height="24">
              </a>
            </td>
            <td class="small">
              <a href="{{ user.get_absolute_url }}" class="item-name">{{ user }}</a>
            </td>
            <td class="small">
              <a href="mailto:{{ user.email }}">{{ user.email }}</a>
            </td>
            <td class="small">
              {% if user.joined_from_ip %}
                {{ user.joined_from_ip }}
              {% else %}
                <i class="text-muted">{% trans "IP removed" context "admin user ip deleted" %}</i>
              {% endif %}
            </td>
          </tr>
        {% endfor %}
      </tbody>
    </table>
  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Ban settings" context "admin ban users form" %}</legend>

    {% form_row form.ban_type %}
    {% form_row form.expires_on %}

  </fieldset>
</div>
<div class="form-fieldset">
  <fieldset>
    <legend>{% trans "Messages" context "admin ban users form" %}</legend>

    {% form_row form.user_message %}
    {% form_row form.staff_message %}

  </fieldset>
</div>
{% endblock form-body %}


{% block form-footer %}
<button class="btn btn-primary btn-sm" name="finalize">
  {% trans "Ban users" context "admin ban users form" %}
</button>
{% endblock %}


{% block javascripts %}
<script type="text/javascript">
  window.misago.initDatepicker({
    elementId: "id_expires_on",
    never: "{% trans 'Never' context 'admin ban users form' %}",
    setDate: "{% trans 'Set date' context 'admin ban users form' %}"
  })
</script>
{% endblock %}
