{% load filters %}
{% load i18n %}

<div class="table-responsive">
    <table class="table table-striped table-sm{% if interactive is True %} table-interactive{% endif %}">
        <thead>
        <th>{% trans "section" %}</th>
        <th>{% trans "title" %}</th>
        <th>{% trans "authors" %}</th>
        <th>{% trans "editor" %}</th>
        <th>{% trans "deadline" %}</th>
        <th>Обновлено</th>
        <th>{% trans "stage" %}</th>
        </thead>
        <tbody>

        {% for post in posts %}
            <tr class="">
                <td data-order="{{ post.section.sort }}">
                    <span class="badge badge-custom" style="background-color: #{{ post.section.color }};">
                        {{ post.section.title }}
                    </span>
                </td>
                <td>
                    <a href="{% url 'posts_show' post.id %}">{{ post }}</a> (<a
                        href="{% url 'posts_edit' post.id %}">{% trans "edit" %}</a>)
                    {% if post.has_text == True %}
                        <span class="badge badge-success">{% trans "has_text" %}</span>
                    {% endif %}
                </td>
                <td>
                    {% for author in post.authors.all %}
                        {% if perms.main.manage_authors %}
                            <a href="{% url 'authors_show' author.id %}">{{ author }}</a>
                        {% else %}
                            {{ author }}
                        {% endif %}
                    {% endfor %}
                </td>
                <td>
                    {% if perms.main.manage_authors %}
                        <a href="{% url 'authors_show' post.editor.id %}">{{ post.editor }}</a>
                    {% else %}
                        {{ post.editor }}
                    {% endif %}
                </td>
                <td class="{% if post.is_overdue is True %}table-danger{% endif %}"
                    data-order="{{ post.finished_at|date:'U' }}">
                    <nobr>{{ post.finished_at|date:'d b Y' }}</nobr>
                </td>
                <td data-order="{{ post.updated_at|date:'U' }}">
                    <nobr>{{ post.updated_at|date:'d b Y' }}</nobr>{% if post.last_updater %},
                    {{ post.last_updater }}{% endif %}
                </td>
                <td data-order="{{ post.stage.sort }}">
                    <span class="badge badge-custom" style="background-color: #{{ post.stage.meta.background }};">
                        {{ post.stage.title }}
                    </span>
                </td>
            </tr>
        {% endfor %}

        </tbody>
    </table>
</div>