{% extends "forum/base.html" %}
{% load i18n %}

{% block forum_content %}
{% for category in category_set %}
<table class="category">
    <caption>
        <a href="{{ category.get_absolute_url }}">{{ category }}</a>
    </caption>
    <thead><!--
        --><tr>
            <th class="forum_name">
                <a href="#">Forum</a>
            </th><!--
            --><th class="threads_counter">
                <a href="#">{% trans "Threads" %}</a>
            </th><!--
            --><th class="replies_counter">
                <a href="#">{% trans "Replies" %}</a>
            </th><!--
            --><th class="last_thread">
                <a href="#">{% trans "Last Thread" %}</a>
            </th>
        </tr>
    </thead>
    {% for forum in category.forum_set.active %}
    <tr class='{{ forloop.counter0|divisibleby:"2"|default:"mark" }}'>
        <td class="forum_name">
            <a href="{{ forum.get_absolute_url }}">{{ forum }}</a>
        </td>
        <td class="threads_counter">
            <span>{{ forum.threads_counter }}</span>
        </td>
        <td class="replies_counter">
            <span>{{ forum.replies_counter }}</span>
        </td>
        <td class="last_thread">
            {% with forum.latest_thread as latest_thread %}
                <span>
                    {% if latest_thread %}
                    <a href="{{ latest_thread.get_absolute_url }}">{{ latest_thread }}</a>
                    {% else %}-{% endif %}
                </span>
            {% endwith %}
        </td>
    </tr>
    {% empty %}
    <tr>
        <td class="warn forum_name">
            {% trans "Click here to add a" %} <a href='{% url admin:forum_forum_add %}?group={{ category.id }}'>{% trans "new forum" %}</a>
        </td>
        <td class="threads_counter">-</td>
        <td class="replies_counter">-</td>
        <td class="last_thread">-</td>
    </tr>
    {% endfor %}

</table>
{% empty %}
<h3>{% trans "There are no categories registered at the moment." %}</h3>
{% if user.is_staff %}
<p>{% trans "Please, add a category" %} <a href='{% url admin:forum_category_add %}'>{% trans "through this link" %}</a>. </p>
{% endif %}
{% endfor %}
{% endblock %}
