{% extends 'board_base.html' %}
{% load i18n %}
{% load mptt_tags %}
{% load forum_tags %}
{% load forum_conversation_tags %}
{% load forum_permission_tags %}
{% load forum_tracking_tags %}

{% block sub_title %}{{ forum.name }}{% endblock sub_title %}

{% block content %}
<div class="flex flex-wrap">
  <div class="w-full">
    <h1 class="text-4xl">{{ forum.name }}</h1>
  </div>
</div>
{% if sub_forums %}
<div class="flex flex-wrap">
  <div class="w-full forumlist-top-controls">
    {% if request.user.is_authenticated %}
    <div class="float-right">
      <a href="{% url 'forum_tracking:mark_subforums_read' forum.pk %}" class="inline-block"><i class="fa fa-check-circle-o">&nbsp;</i>{% trans "Mark subforums read" %}</a>
    </div>
    {% endif %}
  </div>
</div>
{% forum_list sub_forums %}
{% endif %}
{% if forum.is_forum %}
<div class="flex flex-wrap mt-4 mb-3">
  <div class="pr-4 pl-4 w-1/4 forum-actions-block">
    {% get_permission 'can_add_topic' forum request.user as user_can_add_topic %}
    {% if user_can_add_topic %}
    <a href="{% url 'forum_conversation:topic_create' forum.slug forum.pk %}" class="py-3 px-8 text-base font-medium rounded-md border md:py-1 md:px-4 md:text-lg border-orange text-orange">{% trans "New topic" %}</a>
    {% endif %}
  </div>
  <div class="pr-4 pl-4 w-full md:w-2/3">
    {% if topics|length > 0 and request.user.is_authenticated %}
    <div class="float-left">
      <a href="{% url 'forum_tracking:mark_topics_read' forum.pk %}" class="inline-block my-1 text-sm uppercase">{% trans "Mark topics read" %}</a>
    </div>
    {% endif %}
    {% with "pagination-sm justify-content-end" as pagination_size %}
    {% include "partials/pagination.html" %}
    {% endwith %}
  </div>
</div>
{% trans "Announcements" as announcements_title_trans %}
{% with topic_list_title=announcements_title_trans topics=announces hide_if_empty=True unread_topics=unread_topics %}
{% include "forum_conversation/topic_list.html" %}
{% endwith %}
{% trans "Topics" as topics_title_trans %}
{% with topic_list_title=topics_title_trans unread_topics=unread_topics%}
{% include "forum_conversation/topic_list.html" %}
{% endwith %}
<div class="flex flex-wrap mt-3 mb-5">
  <div class="pr-4 pl-4 w-1/4 forum-actions-block">
    {% if user_can_add_topic %}
    <a href="{% url 'forum_conversation:topic_create' forum.slug forum.pk %}" class="py-3 px-8 text-base font-medium rounded-md border md:py-1 md:px-4 md:text-lg border-orange text-orange">{% trans "New topic" %}</a>
    {% endif %}
  </div>
  <div class="pr-4 pl-4 w-full md:w-2/3">
    {% if topics|length > 0 and request.user.is_authenticated %}
    <div class="float-left">
      <a href="{% url 'forum_tracking:mark_topics_read' forum.pk %}" class="inline-block my-1 text-sm uppercase">{% trans "Mark topics read" %}</a>
    </div>
    {% endif %}
    {% with "pagination-sm justify-content-end" as pagination_size %}
    {% include "partials/pagination.html" %}
    {% endwith %}
  </div>
</div>
{% endif %}
{% endblock content %}
