{% extends "site_base.html" %}
{% load thumbnail %}

{% block "metas" %}
    <title>{{ title }} - {{ settings.SITE_TITLE }}</title>
    <meta name="description" content="{{ description }}" />
{% endblock "metas" %}

{% block "breadcrumbs" %}
  <ul class="breadcrumb">
    <li><i class="icon-home"></i> <a href="{% url app_forum-forum-index %}">{{ _('Forum') }}</a> <span class="divider">/</span></li>
    <li><i class="icon-folder-open"></i> {{ myforum.title }}</li>
  </ul>
{% endblock "breadcrumbs" %}

{% block "content" %}
<section id="forum">

  {% if subforos %}
    {% include "rforum/_forum-top.html" %}

    <div class="forum">
      <table class="table table-bordered">
        <thead>
          <tr>
            <th colspan="2">{{ _('SubForum') }}</th>
            <th style="text-align: center;">{{ _('Topics') }}</th>
            <th>{{ _('Last Post') }}</th>
          </tr>
        </thead>
        <tbody>
          {% for forum in subforos %}
          <tr class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
            <td class="forum-image" style="text-align: center;"><img src="{{ STATIC_URL }}img/rforum/forum.gif" alt="{{ forum.title }}"
            title="{{ forum.title }}" style="margin-top: 8px" /></td>
            <td>
              <a href="{% url app_forum-forum-detail forum.slug %}" class="forum-title">{{ forum.title }}</a>
              <p>{{ forum.description|safe }}</p>
              <p>{{ _('Moderators') }}: {% for moder in forum.moderators.all %} <a href="{% url app_forum-userprofile moder %}">{{ moder }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
            </td>
            <td style="text-align: center;">{{ forum.topics.count }}</td>
            <td>{% if forum.topics.all.0.title %}<p><a href="{% url app_forum-topic-list forum.slug forum.topics.all.0.slug %}">{{ forum.topics.all.0.title }}</a></p><p>{{ forum.topics.all.0.date_modified }}</p>{% else %}---{% endif %}</td>
          </tr>
          {% endfor %}
        </tbody>
      </table>
    </div>

    <hr />
  {% endif %}

  {% include "rforum/_forum-top.html" %}
  {% include "rforum/_actions-forum.html" %}

  <div class="forum">
    <table class="table table-bordered">
      <thead>
        <tr>
          <th colspan="2">{{ _('Topics') }}</th>
          <th style="text-align: center;">{{ _('Replies') }}</th>
          <th style="text-align: center;">{{ _('Views') }}</th>
          <th>{{ _('Last Post') }}</th>
        </tr>
      </thead>
      <tbody>
        {% for topic in myforum.topics.all %}
        {% if topic.status = 1 %}
        <tr class="{% if forloop.counter|divisibleby:2 %}even{% else %}odd{% endif %}">
          {% if topic.closed and topic.sticky %}<td style="text-align: center;"><img src="{{ STATIC_URL }}img/rforum/sticky_closed.gif" alt="{{ topic.title }}"{% endif %}
          {% if topic.closed and not topic.sticky %}<td style="text-align: center;"><img src="{{ STATIC_URL }}img/rforum/closed.gif" alt="{{ topic.title }}"{% endif %}
          {% if not topic.closed and topic.sticky %}<td style="text-align: center;"><img src="{{ STATIC_URL }}img/rforum/sticky.gif" alt="{{ topic.title }}"{% endif %}
          {% if not topic.closed and not topic.sticky %}<td style="text-align: center;"><img src="{{ STATIC_URL }}img/rforum/topic.gif" alt="{{ topic.title }}"{% endif %}
          title="{{ topic.title }}" style="margin-top: 8px" /></td>
          <td>
            <a href="{% url app_forum-topic-list myforum.slug topic.slug %}" class="forum-title">{{ topic.title }}</a>
            <p>{{ _('by') }}: <a href="{% url app_forum-userprofile topic.user %}">{{ topic.user }}</a> &rarr; {{ topic.date_created  }}</p>
          </td>
          <td style="text-align: center;">{{ topic.posts.count|add:"-1" }}</td>
          <td style="text-align: center;">{{ topic.hits }}</td>
          <td>
            {% for p in topic.posts.all %}
                {% if forloop.last %}
                    <p><a href="{% url app_forum-topic-list myforum.slug topic.slug %}#{{ p.id }}">#</a> {{ _('by') }}: <a href="{% url app_forum-userprofile p.user %}">{{ p.user }}</a></p><p>{{ p.date_modified }}</p>
                {% endif %}
            {% endfor %}
            </td>
        </tr>
        {% endif %}
        {% endfor %}
      </tbody>
    </table>
  </div>

  {% include "rforum/_actions-forum.html" %}
  {% include "rforum/_forum-bottom.html" %}

</section>
{% endblock "content" %}
