From a570702ae3d7b6f0636e2e6631e6176e9ad0eb5c Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Tue, 2 Oct 2012 16:22:26 -0400 Subject: [PATCH 1/4] add a new subsection edit url map and reference it in the course summary page --- cms/djangoapps/contentstore/views.py | 5 ++++- cms/templates/overview.html | 2 +- cms/urls.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 1443f37c2d..82ead3969e 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -132,6 +132,10 @@ def course_index(request, org, course, name): }) +@login_required +def edit_subsection(request, location): + pass + @login_required def edit_unit(request, location): """ @@ -377,7 +381,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/overview.html b/cms/templates/overview.html index 89d8c3d387..946dcef71c 100644 --- a/cms/templates/overview.html +++ b/cms/templates/overview.html @@ -34,7 +34,7 @@
- + ${subsection.display_name} 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'), From e24dcaead6345e88b4ff8c4cf37370015b1ff5ee Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 3 Oct 2012 10:44:20 -0400 Subject: [PATCH 2/4] initial subsection page converted from static HTML mockup --- cms/djangoapps/contentstore/views.py | 12 ++- cms/templates/edit_subsection.html | 119 +++++++++++++++++++++++++++ 2 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 cms/templates/edit_subsection.html diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 82ead3969e..6a065a2daf 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -134,7 +134,17 @@ def course_index(request, org, course, name): @login_required def edit_subsection(request, location): - pass + # 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', {}) @login_required def edit_unit(request, location): diff --git a/cms/templates/edit_subsection.html b/cms/templates/edit_subsection.html new file mode 100644 index 0000000000..a9a15cd2e3 --- /dev/null +++ b/cms/templates/edit_subsection.html @@ -0,0 +1,119 @@ +<%inherit file="base.html" /> +<%! from django.core.urlresolvers import reverse %> +<%block name="bodyclass">subsection +<%block name="title">CMS Subsection +<%block name="content"> + +
+
+
+ +
+ + +
+ From ca3aecd6ad25b133f84a1ff7a6a9c1fbd4346783 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 3 Oct 2012 14:07:21 -0400 Subject: [PATCH 3/4] add subsection edit page to the project with a shared 'unit' widget that will render out unit lists. Both edit_subsection and overview.html will share this widget --- cms/templates/widgets/units.html | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 cms/templates/widgets/units.html 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. +
+ From 711dc55c73e6de1a795dddef871f3b7c0cdb7330 Mon Sep 17 00:00:00 2001 From: Chris Dodge Date: Wed, 3 Oct 2012 14:16:23 -0400 Subject: [PATCH 4/4] add subsection edit page to the project with a shared 'unit' widget that will render out unit lists. Both edit_subsection and overview.html will share this widget --- cms/djangoapps/contentstore/views.py | 3 +- cms/templates/edit_subsection.html | 62 ++-------------------------- cms/templates/overview.html | 25 ++--------- 3 files changed, 10 insertions(+), 80 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index bfd7704a3e..33bfafea4f 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -144,7 +144,8 @@ def edit_subsection(request, location): if item.location.category != 'sequential': return HttpResponseBadRequest - return render_to_response('edit_subsection.html', {}) + return render_to_response('edit_subsection.html', + {'subsection':item}) @login_required def edit_unit(request, location): diff --git a/cms/templates/edit_subsection.html b/cms/templates/edit_subsection.html index a9a15cd2e3..c9fe9fbda8 100644 --- a/cms/templates/edit_subsection.html +++ b/cms/templates/edit_subsection.html @@ -2,8 +2,10 @@ <%! from django.core.urlresolvers import reverse %> <%block name="bodyclass">subsection <%block name="title">CMS Subsection -<%block name="content"> +<%namespace name="units" file="widgets/units.html" /> + +<%block name="content">
@@ -18,63 +20,7 @@
-
    -
  1. -
    - Motivation for 6.002x -
    - - - -
    -
    -
  2. -
  3. -
    - Administrivia -
    - - - -
    -
    -
  4. -
  5. -
    - Course Overview -
    - - - -
    -
    -
  6. -
  7. - -
  8. -
  9. -
    - Simple Power -
    - - - -
    -
    -
  10. -
  11. - - New Unit - -
  12. -
+ ${units.enum_units(subsection)}
diff --git a/cms/templates/overview.html b/cms/templates/overview.html index f07bfa0a39..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">
@@ -44,27 +47,7 @@
- -
    - % for unit in subsection.get_children(): -
  1. - -
  2. - % endfor -
  3. - - New Unit - -
  4. -
+ ${units.enum_units(subsection)} % endfor