{% extends "base.html" %}
{% load i18n %}
{% block mail_template__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><span class="sort">{% trans "Идентификатор" %}<i></i></span></th>
            <th>{% trans "Русский" %}</th>
            <th>{% trans "Английский" %}</th>
          </tr>
        </thead>
        <tbody>

          {% for template_code, templates_by_language in templates %}
          <tr>

            {% with russian=templates_by_language.0 english=templates_by_language.1 %}
            <td><a href="{% url 'mail_template:mail' russian.id %}" class="link">{{ template_code }}</a></td>
            <td class="b-t__ctrl">
              {% if russian %}
              <a href="{% url "mail_template:mail" russian.id %}" class="link">{{ russian.subject }}</a>
              <a href="{% url "mail_template:preview" russian.id  %}" class="button button_size_S button_type_clear button_icon-only_yes button_fontello button_hover">
                <span class="icon-eye"></span>
                <span class="button__label"></span>
              </a>
              {% endif %}
            </td>

            <td>
              {% if english %}
              {% if english.status == 1%}
              {% trans "Переводится" %}
              {% else %}
              <a href="{% url "mail_template:mail" english.id %}" class="link">{{ english.subject }}</a>
              {% endif %}
              <a href="{% url "mail_template:preview" english.id  %}" class="button button_size_S button_type_clear button_icon-only_yes button_fontello button_hover">
                <span class="icon-eye"></span>
                <span class="button__label"></span>
              </a>
              {% endif %}
            </td>
            {% endwith %}

          </tr>
          {% endfor %}

        </tbody>
      </table>
    </td>
  </tr>
</table>

<a href="{% url 'mail_template: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 %}
