{% 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:data-downloads:request' %}" class="btn btn-primary btn-sm">
    <span class="fa fa-plus-circle"></span>
    {% trans "New downloads" %}
  </a>
</div>
{% endblock %}


{% block table-header %}
<th style="width: 1px;">&nbsp;</th>
<th>{% trans "User" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Requested on" %}</th>
<th style="width: 1px;">&nbsp;</th>
<th>{% trans "Requested by" %}</th>
{% for action in extra_actions %}
  <th style="width: 1px;">&nbsp;</th>
{% endfor %}
<th style="width: 1px;">&nbsp;</th>
{% endblock table-header %}


{% block table-row %}
<td class="pr-0">
  <a href="{{ item.user.get_absolute_url }}">
    <img src="{{ item.user|avatar:40 }}" alt="{% trans 'Avatar' %}" width="24" height="24">
  </a>
</td>
<td class="small">
  <a href="{{ item.user.get_absolute_url }}" class="item-name">
    {{ item.user }}
  </a>
</td>
<td class="small">
  {{ item.get_status_display }}
</td>
<td class="small">
  <abbr data-timestamp="{{ item.requested_on.isoformat }}" data-format="LL">
    {{ item.requested_on }}
  </abbr>
</td>
<td class="pr-0">
  {% if item.requester %}
    <a href="{{ item.requester.get_absolute_url.user }}">
      <img src="{{ item.requester|avatar:40 }}" alt="{% trans 'Avatar' %}" width="24" height="24">
    </a>
  {% else %}
    <img src="{{ BLANK_AVATAR_URL }}" alt="{% trans 'Avatar' %}" width="24" height="24">
  {% endif %}
</td>
<td class="small">
  {% if item.requester %}
    <a href="{{ item.requester.get_absolute_url }}" class="item-name">
      {{ item.requester }}
    </a>
  {% else %}
    <span class="item-name">{{ item.requester_name }}</span>
  {% endif %}
</td>
{% include "misago/admin/generic/list_extra_actions.html" %}
<td>
  {% if item.file %}
    <a href="{{ item.file.url }}" class="btn btn-light btn-sm">
      {% trans "Download" %}
    </a>
  {% else %}
    <button class="btn btn-light btn-sm" disabled>
      {% trans "Download" %}
    </button>
  {% endif %}
</td>
{% endblock table-row %}


{% block blankslate %}
<td colspan="{{ 8|add:extra_actions_len }}">
  {% if active_filters %}
    {% trans "No data downloads matching criteria exist." %}
  {% else %}
    {% trans "No data downloads exist." %}
  {% endif %}
</td>
{% endblock blankslate %}


{% block filters-modal-body %}
<div class="row">
  <div class="col">
    {% form_row filter_form.status %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.user %}
  </div>
</div>
<div class="row">
  <div class="col">
    {% form_row filter_form.requested_by %}
  </div>
</div>
{% endblock filters-modal-body %}
