{% if is_fragment %}
  {% extends "core/base_fragment.jinja" %}

  {# Don't display tabs and errors #}
  {% block tabs %}
  {% endblock %}
  {% block errors %}
  {% endblock %}
{% else %}
  {% extends "core/base.jinja" %}
{% endif %}

{% from "core/macros.jinja" import paginate_htmx %}

{% block title %}
  {% trans %}File moderation{% endtrans %}
{% endblock %}

{% block content %}
  <h3>{% trans %}File moderation{% endtrans %}</h3>
  <div>
    {% for f in object_list %}
      <div
        id="file-{{ loop.index }}"
        style="margin: 2px; padding: 2px; border: solid 1px red; text-align: center"
      >
        {% if f.is_folder %}
          <strong>Folder</strong>
        {% else %}
          <strong>File</strong>
        {% endif %}
        <p>
          <a href="{{ url("core:file_detail", file_id=f.id) }}">{{ f.name }}</a><br/>
          {% trans %}Full name: {% endtrans %}{{ f.get_parent_path()+'/'+f.name }}<br/>
          {% trans %}Owner: {% endtrans %}{{ f.owner.get_display_name() }}<br/>
          {% trans %}Date: {% endtrans %}
          {{ f.date|date(DATE_FORMAT) }} {{ f.date|time(TIME_FORMAT) }}<br/>
        </p>
        <p><button
          hx-get="{{ url('core:file_moderate', file_id=f.id) }}"
          hx-target="#content"
          hx-swap="outerHtml"
        >{% trans %}Moderate{% endtrans %}</button> -
          {% set current_page = url('core:file_moderation') + "?page=" + page_obj.number | string %}
          <button
            hx-get="{{ url('core:file_delete', file_id=f.id) }}?next={{ current_page | urlencode }}&previous={{ current_page | urlencode }}"
            hx-target="#file-{{ loop.index }}"
            hx-swap="outerHtml"
          >{% trans %}Delete{% endtrans %}</button></p>
      </div>
    {% endfor %}
    {{ paginate_htmx(request, page_obj, paginator) }}
  </div>
{% endblock %}
