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


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


{% block table-header %}
<th>{% trans "Warning level" %}</th>
<th style="width: 20%">{% trans "Length" %}</th>
<th style="width: 20%;">{% trans "Replying" %}</th>
<th style="width: 20%;">{% trans "Starting threads" %}</th>
{% for action in extra_actions %}
  <th style="width: 1px;">&nbsp;</th>
{% endfor %}
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="item-name">
  #{{ forloop.counter }} {{ item }}
</td>
<td>
  {% if item.length %}
    <abbr data-time-period="{{ item.length }}">
      {{ item.length }}
    </abbr>
  {% else %}
    {% trans "Permanent" %}
  {% endif %}
</td>
<td>
  {% if item.restricts_posting_replies == 0 %}
    <div class="text-success">
      <span class="fa fa-check-circle"></span>
      {% trans "Not restricted" %}
    </div>
  {% elif item.restricts_posting_replies == 1 %}
    <div class="text-warning">
      <span class="fa fa-exclamation-circle"></span>
      {% trans "Moderated" %}
    </div>
  {% else %}
    <div class="text-danger">
      <span class="fa fa-times-circle"></span>
      {% trans "Forbidden" %}
    </div>
  {% endif %}
</td>
<td>
  {% if item.restricts_posting_threads == 0 %}
    <div class="text-success">
      <span class="fa fa-check-circle"></span>
      {% trans "Not restricted" %}
    </div>
  {% elif item.restricts_posting_threads == 1 %}
    <div class="text-warning">
      <span class="fa fa-exclamation-circle"></span>
      {% trans "Moderated" %}
    </div>
  {% else %}
    <div class="text-danger">
      <span class="fa fa-times-circle"></span>
      {% trans "Forbidden" %}
    </div>
  {% endif %}
</td>
{% include "misago/admin/generic/list_extra_actions.html" %}
<td>
  {% if not forloop.last %}
    <form action="{% url 'misago:admin:users:warnings:down' pk=item.pk %}" method="post">
      {% csrf_token %}
      <button class="btn btn-light" data-tooltip="top" title="{% trans 'Move down' %}">
        <span class="fa fa-chevron-down"></span>
      </button>
    </form>
  {% else %}
    &nbsp;
  {% endif %}
</td>
<td>
  {% if not forloop.first %}
    <form action="{% url 'misago:admin:users:warnings:up' pk=item.pk %}" method="post">
      {% csrf_token %}
      <button class="btn btn-light" data-tooltip="top" title="{% trans 'Move up' %}">
        <span class="fa fa-chevron-up"></span>
      </button>
    </form>
  {% else %}
    &nbsp;
  {% endif %}
</td>
<td>
  <a href="{% url 'misago:admin:users:warnings:edit' pk=item.pk %}" class="btn btn-primary" data-tooltip="top" title="{% trans 'Edit' %}">
    <span class="fa fa-pencil"></span>
  </a>
</td>
<td>
  <form action="{% url 'misago:admin:users:warnings:delete' pk=item.pk %}" method="post" data-delete-confirmation="true">
    {% csrf_token %}
    <button class="btn btn-danger" data-tooltip="top" title="{% trans 'Delete' %}">
      <span class="fa fa-times"></span>
    </button>
  </form>
</td>
{% endblock %}


{% block blankslate %}
<td colspan="{{ 8|add:extra_actions_len }}">
  {% trans "No warning levels are set." %}
</td>
{% endblock blankslate %}


{% block javascripts %}
<script type="text/javascript">
  window.misago.initConfirmation(
    "[data-delete-confirmation]",
    "{% trans 'Are you sure you want to delete this warning level?' %}"
  )
</script>
{% endblock %}
