## mako

<%! main_css = "style-discussion-main" %>

<%page expression_filter="h"/>
<%inherit file="../main.html" />
<%namespace name='static' file='../static_content.html'/>
<%def name="online_help_token()"><% return "discussions" %></%def>
<%!
import json
from django.utils.translation import ugettext as _, ungettext
from django.template.defaultfilters import escapejs
from django.core.urlresolvers import reverse

from django_comment_client.permissions import has_permission
from openedx.core.djangolib.js_utils import dump_js_escaped_json, js_escaped_string
%>

<%block name="bodyclass">discussion discussion-user-profile</%block>
<%block name="pagetitle">${_("Discussion - {course_number}").format(course_number=course.display_number_with_default)}</%block>

<%block name="headextra">
<%include file="_js_head_dependencies.html" />
</%block>

<%block name="js_extra">
<%include file="_js_body_dependencies.html" />
<%static:require_module module_name="discussion/js/discussion_profile_page_factory" class_name="DiscussionProfilePageFactory">
    profile_page_context = {
        'courseSettings': ${course_settings | n, dump_js_escaped_json},
        'courseId': '${unicode(course.id) | n, js_escaped_string}',
        'courseName': '${course.display_name_with_default | n, js_escaped_string}',
        'contentInfo': ${annotated_content_info | n, dump_js_escaped_json},
        'userInfo': ${user_info | n, dump_js_escaped_json},
        'roles': ${roles | n, dump_js_escaped_json},
        'threads': ${threads | n, dump_js_escaped_json},
        'page': ${page | n, dump_js_escaped_json},
        'sortPreference': '${sort_preference | n, js_escaped_string}',
        'numPages': ${num_pages | n, dump_js_escaped_json}
    }

    DiscussionProfilePageFactory(_.extend(
        {
            el: $('.discussion-user-profile-board')
        },
        profile_page_context
    ));
</%static:require_module>
</%block>

<%include file="../courseware/course_navigation.html" args="active_page='discussion'" />

<%block name="content">
<section class="discussion inline-discussion discussion-user-profile-board page-content-container">
    <header class="page-header">
        <div class="page-header-main">
            <div class="sr-is-focusable" tabindex="-1"></div>
            <div>
                <h2 class="discussion-profile-title">${_("Discussion")}</h2>
                <%def name="span(num)"><span class="discussion-count">${num}</span></%def>
                <span class="user-name"><a href="${learner_profile_page_url}">${django_user.username}</a></span>
                <span class="discussion-profile-info">
                    <span class="user-roles">${", ".join(_(role_name) for role_name in django_user_roles)}</span>
                </span>
                <div class="discussion-profile-count">
                    <span class="discussion-profile-info threads-count">${ungettext('%s discussion started', '%s discussions started', profiled_user['threads_count']) % span(profiled_user['threads_count'])}</span>
                    <span class="discussion-profile-info  comments-count">${ungettext('%s comment', '%s comments', profiled_user['comments_count']) % span(profiled_user['comments_count'])}</span>
                </div>
            </div>
        </div>
    </header>
    <div class="page-content">
        <main id="main" aria-label="Content" tabindex="-1" class="discussion-column">
            <div class="course-content discussion-module discussion-user-threads"
                data-course-id="${course.id}"
                data-course-name="${course.display_name_with_default}"
                data-threads="${threads}"
                data-user-info="${user_info}"
                data-user-id="${django_user.id}"
                data-page="${page}"
                data-num-pages="${num_pages}"
                data-user-create-comment="${json.dumps(can_create_comment)}"
                data-user-create-subcomment="${json.dumps(can_create_subcomment)}"
                data-read-only="false"
                data-sort-preference="${sort_preference}"
                data-flag-moderator="${json.dumps(flag_moderator)}"
                data-user-group-id="${user_group_id}">
            </div>
        </main>
    </div>
</section>
</%block>

<%include file="_underscore_templates.html" />
<%include file="_thread_list_template.html" />
