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

{% block forum_content %}
    <div class="row">

        {% if forum.children.count %}
            <table class="category">
                <caption>{% trans "Sub-forums" %}</caption>
                <thead>
                <tr>
                    <th class="name"><a href="#">{% trans "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="#">Last Thread</a></th>
                </tr>
                </thead>
                <tbody>
                {% for child in forum.children.all %}
                    <tr class='{{ forloop.counter0|divisibleby:"2"|default:"mark" }}'>
                        <td class="name"><a href='{{ child.get_absolute_url }}'>{{ child }}</a></td>
                        <td class="threads_counter">{{ child.thread_counter }}</td>
                        <td class="replies_counter">{{ child.reply_counter }}</td>
                        <td class="last_thread">{{ child.last_thread|default:"-" }}</td>
                    </tr>
                {% endfor %}
                </tbody>
            </table>
        {% endif %}
    </div>

    {% include "forum/includes/breadcrumbs.html" %}

    <div class="row">
        <div class="actions">
            <a href='{% url 'forum:new_thread' forum.id %}'>
                <button class="tiny">{% trans "New thread" %}</button>
            </a>
        </div>

        <table class="forum">
            <thead>
            <tr>
                <th class="thread">
                    <a href='?order_by=+title'>{% trans "Title" %}</a>
                </th>
                <th class="author">
                    <a href="?order_by=author">{% trans "Author" %}</a>
                </th>
                <th class="replies_counter">
                    <a href="?order_by=reply_counter">{% trans "Replies" %}</a>
                </th>
                <th class="views_counter">
                    <a href="?order_by=view_counter">{% trans "Views" %}</a>
                </th>
            </tr>
            </thead>
            <tbody>
            {% for thread in object_list %}
                <tr class='{{ forloop.counter0|divisibleby:"2"|default:"mark" }}'>
                    <td class="thread">
                        <a href="{{ thread.get_absolute_url }}">{{ thread }}</a>
                    </td>
                    <!--
                                -->
                    <td class="author">
                        {% with thread.author as thread_author %}
                            <a href="{{ thread_author.get_absolute_url }}">{{ thread_author }}</a>
                        {% endwith %}
                    </td>
                    <!--
                                -->
                    <td class="replies_counter">
                        {{ thread.replies_counter }}
                    </td>
                    <!--
                                -->
                    <td class="views_counter">
                        {{ thread.views_counter }}
                    </td>
                </tr>
            {% empty %}
                <tr>
                    <td class="thread">{% trans "No threads found." %}</td>
                    <!--
                                -->
                    <td class="author">-</td>
                    <!--
                                -->
                    <td class="replies_counter">-</td>
                    <!--
                                -->
                    <td class="views_counter">-</td>
                </tr>
            {% endfor %}
            </tbody>
        </table>
        {% include "forum/paginate.html" %}
    </div>
{% endblock %}
