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


{% block page-actions %}
<div class="page-actions">
  <a href="{% url 'misago:admin:users:bans:new' %}" class="btn btn-success">
    <span class="fa fa-plus-circle"></span>
    {% trans "New ban" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th style="width: 30%;">{% trans "Ban" %}</th>
<th style="width: 30%;">{% trans "Type" %}</th>
<th>{% trans "Expires on" %}</th>
{% for action in extra_actions %}
<th style="width: 1%;">&nbsp;</th>
{% endfor %}
<th style="width: 1%;">&nbsp;</th>
<th style="width: 1%;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="item-name">
  {{ item.banned_value }}
</td>
<td>
  {% if item.registration_only %}
    {% blocktrans trimmed with check_type=item.get_check_type_display %}
      {{ check_type }}, registration only
    {% endblocktrans %}
  {% else %}
    {{ item.get_check_type_display }}
  {% endif %}
</td>
<td{% if item.is_expired %} class="text-muted"{% endif %}>
  {% if item.expires_on %}
    <abbr class="moment" data-iso="{{ item.expires_on.isoformat }}" data-format="lll"></abbr>
  {% else %}
    <em>{% trans "Never" %}</em>
  {% endif %}
</td>
{% for action in extra_actions %}
<td class="row-action">
  <a href="{% url action.link pk=item.pk %}" class="btn btn-{% if action.style %}{{ action.style }}{% else %}default{% endif %} tooltip-top" title="{{ action.name }}">
    <span class="{{ action.icon }}"></span>
  </a>
</td>
{% endfor %}
<td class="row-action">
  <a href="{% url 'misago:admin:users:bans:edit' pk=item.pk %}" class="btn btn-primary tooltip-top" title="{% trans "Edit" %}">
    <span class="fa fa-pencil"></span>
  </a>
</td>
<td class="row-action">
  <form action="{% url 'misago:admin:users:bans:delete' pk=item.pk %}" method="post" class="delete-prompt">
    <button class="btn btn-danger tooltip-top" title="{% trans "Remove" %}">
      {% csrf_token %}
      <span class="fa fa-times"></span>
    </button>
  </form>
</td>
{% endblock %}


{% block emptylist %}
<td colspan="{{ 6|add:extra_actions_len }}">
  {% if active_filters %}
  <p>{% trans "No bans matching search criteria have been found" %}</p>
  {% else %}
  <p>{% trans "No bans are currently set." %}</p>
  {% endif %}
</td>
{% endblock emptylist %}


{% block javascripts %}
{{ block.super }}
<script type="text/javascript">
  $(function() {
    $('.delete-prompt').submit(function() {
      var decision = confirm("{% trans "Are you sure you want to remove this ban?" %}");
      return decision;
    });
  });
</script>
{% endblock %}


{% block modal-title %}
{% trans "Search bans" %}
{% endblock modal-title %}


{% block modal-body %}
<div class="row">
  <div class="col-md-6">
    {% form_row search_form.check_type %}
  </div>
  <div class="col-md-6">
    {% form_row search_form.value %}
  </div>
</div>
<div class="row">
  <div class="col-md-6">
    {% form_row search_form.registration_only %}
  </div>
  <div class="col-md-6">
    {% form_row search_form.state %}
  </div>
</div>
{% endblock modal-body %}

