(r'^admin/news/' + GENERIC_REGEX, 'admin_news'),
(r'^admin/targets/' + GENERIC_REGEX, 'admin_targets'),
(r'^course/(?P<course_id>\d+)/reseq$', 'course_reseq'),
+ (ITEM_PREFIX + r'reseq', 'item_heading_reseq'),
# (r'^admin/terms/(?P<term_id>\d+)/$', 'admin_term_edit'),
# (r'^admin/terms/(?P<term_id>\d+)/delete$', 'admin_term_delete'),
# (r'^admin/terms/$', 'admin_term'),
#------------------------------------------------------------
# resequencing items
-@instructors_only
-def course_reseq(request, course_id):
- course = get_object_or_404(models.Course, pk=course_id)
+def _reseq(request, course, parent_heading):
new_order = request.POST['new_order'].split(',')
# new_order is now a list like this: ['item_3', 'item_8', 'item_1', ...].
# get at the ints.
new_order = [int(n.split('_')[1]) for n in new_order]
print >> sys.stderr, new_order
- # we are at top level, so parent-heading is null.
- the_items = list(course.item_set.filter(parent_heading=None).order_by('sort_order'))
+ the_items = list(course.item_set.filter(parent_heading=parent_heading).order_by('sort_order'))
# sort the items by position in new_order
the_items.sort(key=lambda item: new_order.index(item.id))
for newnum, item in enumerate(the_items):
item.save()
return HttpResponse("'ok'");
-# fixme, need to implement for subheading reordering too.
+@instructors_only
+def course_reseq(request, course_id):
+ course = get_object_or_404(models.Course, pk=course_id)
+ parent_heading = None
+ return _reseq(request, course, parent_heading)
+
+@instructors_only
+def item_heading_reseq(request, course_id, item_id):
+ course = get_object_or_404(models.Course, pk=course_id)
+ item = get_object_or_404(models.Item, pk=item_id, course__id=course_id)
+ parent_heading = item
+ return _reseq(request, course, parent_heading)
</table>
</div>
</div>
+
+ <div py:def="item_reorder_panel()" py:strip="True">
+ <div id="reorder_panel" class="little_action_panel">
+ <a href="javascript:doReorder();">Reorder items</a>
+ </div>
+ <div style="display: none;">
+ <span id="i18n-save-order">Save Ordering</span>
+ <span id="i18n-reorder-items">Reorder Items</span>
+ <span id="i18n-new-order-saved">The new ordering has been saved.</span>
+ <div id="ropanelmessage" style="clear: right; width: 10em;"
+ class="little_action_panel">Drag the items around. Then click Save Ordering, above.</div>
+ </div>
+ </div>
+
</html>
+
<div py:if="instructs(request.user, course)" id="edit_course" class="little_action_panel">
<a href="${course.course_url()}edit/">Edit course details</a>
</div>
- <div id="reorder_panel" class="little_action_panel">
- <a href="javascript:doReorder();">Reorder items</a>
- </div>
-
+ ${item_reorder_panel()}
${show_tree(item_tree, edit=is_editor)}
-
<div py:if="is_editor">${add_subs()}</div>
- <div style="display: none;">
- <span id="i18n-save-order">Save Ordering</span>
- <span id="i18n-reorder-items">Reorder Items</span>
- <span id="i18n-new-order-saved">The new ordering has been saved.</span>
- <div id="ropanelmessage" style="clear: right; width: 10em;"
- class="little_action_panel">Drag the items around. Then click Save Ordering, above.</div>
- </div>
</body>
</html>
<p py:if="not item_tree">
There are no items in this section.
</p>
+ ${item_reorder_panel()}
${show_tree(item_tree, edit=is_editor)}
<div py:if="is_editor">${add_subs(item)}</div>
</body>