diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 6c90e55d1a..33bfafea4f 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -132,6 +132,21 @@ def course_index(request, org, course, name): }) +@login_required +def edit_subsection(request, location): + # check that we have permissions to edit this item + if not has_access(request.user, location): + raise PermissionDenied() + + item = modulestore().get_item(location) + + # make sure that location references a 'sequential', otherwise return BadRequest + if item.location.category != 'sequential': + return HttpResponseBadRequest + + return render_to_response('edit_subsection.html', + {'subsection':item}) + @login_required def edit_unit(request, location): """ @@ -377,7 +392,6 @@ def save_item(request): if not has_access(request.user, item_location): raise PermissionDenied() - logging.debug(request.POST['data']) if request.POST['data']: data = request.POST['data'] modulestore().update_item(item_location, data) diff --git a/cms/templates/edit_subsection.html b/cms/templates/edit_subsection.html new file mode 100644 index 0000000000..c9fe9fbda8 --- /dev/null +++ b/cms/templates/edit_subsection.html @@ -0,0 +1,65 @@ +<%inherit file="base.html" /> +<%! from django.core.urlresolvers import reverse %> +<%block name="bodyclass">subsection +<%block name="title">CMS Subsection + +<%namespace name="units" file="widgets/units.html" /> + +<%block name="content"> +
+
+
+
+
+ + +
+
+ + +
+
+ + ${units.enum_units(subsection)} +
+
+ + +
+
+
+ + +
+ diff --git a/cms/templates/overview.html b/cms/templates/overview.html index a24dc6b8ab..f4ae4abe4d 100644 --- a/cms/templates/overview.html +++ b/cms/templates/overview.html @@ -2,6 +2,9 @@ <%! from django.core.urlresolvers import reverse %> <%block name="title">CMS Courseware Overview +<%namespace name="units" file="widgets/units.html" /> + + <%block name="content">
@@ -34,7 +37,7 @@ - -
    - % for unit in subsection.get_children(): -
  1. - -
  2. - % endfor -
  3. - - New Unit - -
  4. -
+ ${units.enum_units(subsection)} % endfor diff --git a/cms/templates/widgets/units.html b/cms/templates/widgets/units.html new file mode 100644 index 0000000000..12b0d33039 --- /dev/null +++ b/cms/templates/widgets/units.html @@ -0,0 +1,27 @@ +<%! from django.core.urlresolvers import reverse %> + + +<%def name="enum_units(subsection)"> +
    + % for unit in subsection.get_children(): +
  1. + +
  2. + % endfor +
  3. + + New Unit + +
  4. +
+ diff --git a/cms/urls.py b/cms/urls.py index 94b247ee54..e35c756c74 100644 --- a/cms/urls.py +++ b/cms/urls.py @@ -10,6 +10,7 @@ import django.contrib.auth.views urlpatterns = ('', url(r'^$', 'contentstore.views.index', name='index'), url(r'^edit/(?P.*?)$', 'contentstore.views.edit_unit', name='edit_unit'), + url(r'^subsection/(?P.*?)$', 'contentstore.views.edit_subsection', name='edit_subsection'), url(r'^delete/(?P.*?)$', 'contentstore.views.delete_unit', name='delete_unit'), url(r'^preview_component/(?P.*?)$', 'contentstore.views.preview_component', name='preview_component'), url(r'^save_item$', 'contentstore.views.save_item', name='save_item'),