{% extends "base.html" %}
{% load i18n %}
{% block page__menu %}cur{% endblock %}
{% block content %}
<div class="title">
    <h2>{% trans "Страницы" %}</h2>
</div>
{% if messages %}
    {% for message in messages %}
        <p class="{{ message.tags }}">{{ message }}</p>
    {% endfor %}
{% endif %}
<table class="g g_max g_padding-t_XL g_gap_L">
    <tr>
        <td class="c">
            <table class="b-t t-sort t-sort_pages">
                <thead>
                    <tr>
                        <th>{% trans "№" %}</th>
                        <th><span class="sort">{% trans "Идентификатор" %}<i></i></span></th>
                        {% for _, status in statuses %}
                        <th>{{ status }}</th>
                        {% endfor %}
                        <th class="fixed-width">{% trans "Удалить" %}</th>
                    </tr>
                </thead>
                <tbody>
                    {% for page, page_translations in pages %}
                    <tr>
                      <td>{% if page.is_removable %}{{ page.order }}{% endif %}</td>
                        <td>{{ page.slug }}</td>

                        {% for translation in page_translations %}
                          <td class="b-t__ctrl">
                          {% if translation %}
                          <a href="{{ translation.get_absolute_url }}" class="link">{% trans 'изменить' %}</a>
                          <a href="{% url 'page:preview' slug=translation.page.slug status=translation.status language='ru' %}" class="link">{% trans 'RU' %}</a>
                          {% if translation.status == page_translation_model.STATUS_DOWNLOADED or translation.status == page_translation_model.STATUS_PUBLISHED  %}
                            <a href="{% url 'page:preview' slug=translation.page.slug status=translation.status language='en' %}" class="link">{% trans 'EN' %}</a>
                          {% endif %}
                          {% endif %}
                          </td>
                        {% endfor %}

                        <td class="b-t_min fixed-width">
                          {% if page.is_removable %}
                          <form action="{% url 'page:delete' slug=page.slug %}" method="POST">
                            {% csrf_token %}
                            <button class="button button_size_S button_type_clear button_icon-only_yes button_fontello button_hover" type="submit">
                                <span class="button__ground"></span>
                                <span class="icon-cancel"></span>
                            </button>
                          </form>
                          {% endif %}

                    </tr>
                    {% endfor %}
                </tbody>
            </table>
        </td>
    </tr>
</table>
<a href="{% url 'page:create' %}">
<button class="button button_size_L button_type_action button_add">
    <span class="button__ground"></span>
    <span class="button__label">
        {% trans "Добавить" %}
    </span>
</button>
</a>
{% endblock %}
