{% extends "sveedocuments/board/subbase_inserts.html" %}
{% load i18n mptt_tags autobreadcrumb guardian_tags documents_admin %}

{% block board_content %}
    <div class="clearfix">
        {% if 'sveedocuments.add_insert' in perms %}
            <a class="secondary button right" href="{% url 'sveedocuments:insert-add' %}">{% trans "Add a new insert document" %}</a>
        {% endif %}
        <h2>{% trans "Insert documents" %}</h2>
    </div>
    
    <table class="full">
        <thead>
            <tr>
                <th class="title-cell col-odd">{% trans "Title" %}</th>
                <th class="slug-cell col-even">{% trans "Slug" %}</th>
                <th class="visible-cell col-odd">{% trans "Visibility" %}</th>
                <th class="modified-cell col-even">{% trans "Last modified" %}</th>
                <th class="actions-cell col-odd">#</th>
            </tr>
        </thead>
        <tbody>
    {% for item in insert_list %}
            {% get_obj_perms user for item as "insert_perms" %}
            <tr id="insert-row-{{ item.id }}">
                <th class="title-cell col-odd">
                    {% if "change_insert" in insert_perms or 'sveedocuments.change_insert' in perms %}
                        <a href="{% url 'sveedocuments:insert-edit' item.slug %}">{{ item.title }}</a>
                    {% else %}
                        {{ item.title }}
                    {% endif %}
                </th>
                <td class="slug-cell col-even">{{ item.slug }}</td>
                <td class="visible-cell col-odd">{{ item.get_visible_display }}</td>
                <td class="modified-cell col-even">{{ item.modified|date:"l d F Y à H:i"|title }}</td>
                <td class="actions-cell col-odd">
                    {% if "delete_insert" in insert_perms or 'sveedocuments.delete_insert' in perms %}
                        <a href="{% url 'sveedocuments:insert-delete' item.slug %}">{% trans "Delete" %}</a>
                    {% else %}
                        -
                    {% endif %}
                </td>
            </tr>
        </tr>
    {% endfor %}
        </tbody>
    </table>
{% endblock %}
