67 lines
2.4 KiB
HTML
67 lines
2.4 KiB
HTML
<%! from django.utils.translation import ugettext as _ %>
|
|
<%! from django.core.urlresolvers import reverse %>
|
|
<%! from contentstore.utils import compute_publish_state %>
|
|
<%! from xmodule.modulestore.django import loc_mapper %>
|
|
|
|
<!--
|
|
This def will enumerate through a passed in subsection and list all of the units
|
|
-->
|
|
<%def name="enum_units(subsection, actions=True, selected=None, sortable=True, subsection_units=None)">
|
|
<ol ${'class="sortable-unit-list"' if sortable else ''}>
|
|
<%
|
|
if subsection_units is None:
|
|
subsection_units = subsection.get_children()
|
|
%>
|
|
<%
|
|
subsection_locator = loc_mapper().translate_location(context_course.location.course_id, subsection.location, False, True)
|
|
%>
|
|
% for unit in subsection_units:
|
|
<%
|
|
unit_locator = loc_mapper().translate_location(context_course.location.course_id, unit.location, False, True)
|
|
%>
|
|
<li class="courseware-unit unit is-draggable" data-locator="${unit_locator}"
|
|
data-parent="${subsection_locator}">
|
|
|
|
<%include file="_ui-dnd-indicator-before.html" />
|
|
|
|
<%
|
|
unit_state = compute_publish_state(unit)
|
|
if unit.location == selected:
|
|
selected_class = 'editing'
|
|
else:
|
|
selected_class = ''
|
|
%>
|
|
<div class="section-item ${selected_class}">
|
|
<a href="${unit_locator.url_reverse('unit')}" class="${unit_state}-item">
|
|
<span class="unit-name">${unit.display_name_with_default}</span>
|
|
</a>
|
|
% if actions:
|
|
<div class="item-actions">
|
|
<ul class="actions-list">
|
|
<li class="actions-item delete">
|
|
<a href="#" data-tooltip="${_("Delete this unit")}" class="delete-unit-button action" data-locator="${unit_locator}"><i class="icon-trash"></i><span class="sr">${_("Delete unit")}</span></a>
|
|
</li>
|
|
<li class="actions-item drag">
|
|
<span data-tooltip="${_("Drag to sort")}" class="drag-handle unit-drag-handle action"><span class="sr"> ${_("Drag to reorder unit")}</span></span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
% endif
|
|
</div>
|
|
|
|
<%include file="_ui-dnd-indicator-after.html" />
|
|
</li>
|
|
% endfor
|
|
<li class="courseware-unit add-new-unit">
|
|
<%include file="_ui-dnd-indicator-initial.html" />
|
|
|
|
<a href="#" class="new-unit-item" data-category="${new_unit_category}" data-parent="${subsection_locator}">
|
|
<i class="icon-plus"></i> ${_("New Unit")}
|
|
</a>
|
|
</li>
|
|
</ol>
|
|
</%def>
|
|
|
|
|
|
|