added item-reordering for subheading-contents as well.
authorgfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 25 Mar 2009 02:52:37 +0000 (02:52 +0000)
committergfawcett <gfawcett@6d9bc8c9-1ec2-4278-b937-99fde70a366f>
Wed, 25 Mar 2009 02:52:37 +0000 (02:52 +0000)
git-svn-id: svn://svn.open-ils.org/ILS-Contrib/servres/trunk@216 6d9bc8c9-1ec2-4278-b937-99fde70a366f

conifer/syrup/urls.py
conifer/syrup/views.py
conifer/templates/components/course.xhtml
conifer/templates/course_detail.xhtml
conifer/templates/item_heading_detail.xhtml

index aa9a4f9..5453b52 100644 (file)
@@ -45,6 +45,7 @@ urlpatterns = patterns('conifer.syrup.views',
     (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'),
index bd8820a..ac79998 100644 (file)
@@ -1124,16 +1124,13 @@ def course_feeds(request, course_id, feed_type):
 #------------------------------------------------------------
 # 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):
@@ -1141,4 +1138,15 @@ def course_reseq(request, course_id):
         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)
index 78bcc40..80cf5f1 100644 (file)
@@ -92,4 +92,19 @@ searchtext = _('search this course...')
       </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>
+
index 1fe6967..081ed5b 100644 (file)
@@ -20,21 +20,10 @@ is_editor = course.can_edit(request.user)
     <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>
index 789df89..e90bf26 100644 (file)
@@ -20,6 +20,7 @@ item_tree = course.item_tree(subtree=item)
     <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>