{% 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 %}
{% get_permission 'can_rename_forum' forum request.user as user_can_rename_forum %}
{% get_permission 'can_manage_moderator' forum request.user as user_can_manage_moderator %}
<div class="row">
  <div class="col-12">
    <h1>
        {{ forum.name }}
        {% if user_can_rename_forum or user_can_manage_moderator %}
        <div class="btn-group moderation-dropdown">
          <button id="id_dropdown_moderation_menu_button" class="btn btn-warning btn-sm dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fas fa-edit">&nbsp;&nbsp;</i><span class="caret"></span></button>
          <div class="dropdown-menu" aria-labelledby="id_dropdown_moderation_menu_button" style="min-width:13rem;">
            {% if user_can_rename_forum %}<a href="{% url 'forum:rename' forum.pk %}" title="{% trans "Rename forum" %}" class="dropdown-item">{% trans "Rename forum" %}</a>{% endif %}
            {% if user_can_manage_moderator %}<a href="{% url 'moderators'%}" title="{% trans "Manage moderators" %}"  class="dropdown-item">{% trans "Manage moderators" %}</a>{% endif %}
          </div>
        </div>
        {% endif %}
    </h1>
    
  </div>
</div>
{% if sub_forums %}
<div class="row">
  <div class="forumlist-top-controls col-12">
    {% if request.user.is_authenticated %}
    <div class="float-right">
      <a href="{% url 'forum_tracking:mark_subforums_read' forum.pk %}" class="d-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="mt-4 mb-3 row">
  <div class="col-6 col-md-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="btn btn-primary btn-sm"><i class="fa fa-comments fa-lg"></i>&nbsp;{% trans "New topic" %}</a>
    {% endif %}
  </div>
  <div class="col-12 col-md-8">
    {% if topics|length > 0 and request.user.is_authenticated %}
    <div class="float-right small">
      <a href="{% url 'forum_tracking:mark_topics_read' forum.pk %}" class="my-1 d-inline-block"><i class="fas fa-check-circle">&nbsp;</i>{% 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="mt-3 mb-5 row">
  <div class="col-6 col-md-4 forum-actions-block">
    {% if user_can_add_topic %}
    <a href="{% url 'forum_conversation:topic_create' forum.slug forum.pk %}" class="btn btn-primary btn-sm"><i class="fa fa-comments fa-lg"></i>&nbsp;{% trans "New topic" %}</a>
    {% endif %}
  </div>
  <div class="col-12 col-md-8">
    {% if topics|length > 0 and request.user.is_authenticated %}
    <div class="float-right small">
      <a href="{% url 'forum_tracking:mark_topics_read' forum.pk %}" class="my-1 d-inline-block"><i class="fas fa-check-circle">&nbsp;</i>{% 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 %}
