{% load i18n %}

{% include "discussion_templates/_underscore_templates.html" %}
{% include "discussion_templates/_thread_list_template.html" %}

<div class="discussion-module" data-discussion-id="{{ discussion_id }}"
    data-user-create-comment="{{ can_create_comment|yesno:"true,false" }}"
    data-user-create-subcomment="{{ can_create_subcomment|yesno:"true,false" }}"
    data-read-only="{% if can_create_thread %}false{% else %}true{% endif %}">
    {% if not user.is_authenticated %}
        <div class="page-banner">
            <div class="alert alert-warning" role="alert">
                <span class="icon icon-alert fa fa-warning" aria-hidden="true"></span>
                <div class="message-content">{{ login_msg }}</div>
            </div>
        </div>
        <br>
    {% endif %}

    <div class="discussion-module-header">
        <h3 class="hd hd-3 discussion-module-title">
            {% filter force_escape %}
                {% blocktrans with title=display_name %}{{ title }}{% endblocktrans %}
            {% endfilter %}
        </h3>
        <div class="inline-discussion-topic">
            <span class="inline-discussion-topic-title">{% trans "Topic:" as tmsg %} {{tmsg|force_escape}}</span> 
            {{ discussion_category }}
            {% if discussion_target %}
                / {{ discussion_target }}
            {% endif %}
        </div>
    </div>
    <button class="discussion-show btn"
        data-discussion-id="{{ discussion_id }}"
        {% if not user.is_authenticated %}disabled="disabled"{% endif %}>
        <span class="button-text">{% trans "Show Discussion" as tmsg %} {{tmsg|force_escape}}</span>
    </button>

</div>
<script type="text/javascript">
var $$course_id = "{{ course_id|escapejs }}";

function DiscussionInlineBlock(runtime, element) {
    'use strict';
    var el = $(element).find('.discussion-module');
    new DiscussionInlineView({ el: el, readOnly: el.data('read-only') });
}
</script>
