<%page args="section_data"/>
<%namespace name='static' file='../../static_content.html'/>
<%!
from django.utils.translation import ugettext as _
from courseware.courses import get_studio_url
from microsite_configuration import microsite
from openedx.core.djangoapps.course_groups.partition_scheme import get_cohorted_user_partition
%>


<div class="cohort-management"
     data-cohorts_url="${section_data['cohorts_url']}"
     data-upload_cohorts_csv_url="${section_data['upload_cohorts_csv_url']}"
     data-course_cohort_settings_url="${section_data['course_cohort_settings_url']}"
     data-discussion-topics-url="${section_data['discussion_topics_url']}"
>
</div>


<%block name="js_extra">
<%static:require_module module_name="js/groups/views/cohorts_dashboard_factory" class_name="CohortsFactory">
    <%
    cohorted_user_partition = get_cohorted_user_partition(course)
    content_groups = cohorted_user_partition.groups if cohorted_user_partition else []
    %>
    var cohortUserPartitionId = ${cohorted_user_partition.id if cohorted_user_partition else 'null'},
        contentGroups = [
            % for content_group in content_groups:
            {
                id: ${content_group.id},
                name: "${content_group.name | h}",
                user_partition_id: cohortUserPartitionId
            },
            % endfor
        ];
    CohortsFactory(contentGroups, '${get_studio_url(course, 'group_configurations') | h}');
</%static:require_module>
</%block>
<div class="cohort-state-message"></div>
