From 55d6aff4c16d19730af189a23671f8637ff1d81e Mon Sep 17 00:00:00 2001 From: Calen Pennington Date: Wed, 3 Oct 2012 14:54:17 -0400 Subject: [PATCH] Wire up the unit location display --- cms/djangoapps/contentstore/views.py | 19 +++++++++++-- cms/static/sass/_cms_mixins.scss | 2 +- cms/templates/unit.html | 42 ++++++++++++++-------------- cms/templates/widgets/units.html | 16 +++++++++-- 4 files changed, 51 insertions(+), 28 deletions(-) diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py index 33bfafea4f..8c8a895652 100644 --- a/cms/djangoapps/contentstore/views.py +++ b/cms/djangoapps/contentstore/views.py @@ -144,8 +144,9 @@ def edit_subsection(request, location): if item.location.category != 'sequential': return HttpResponseBadRequest - return render_to_response('edit_subsection.html', - {'subsection':item}) + return render_to_response('edit_subsection.html', + {'subsection': item}) + @login_required def edit_unit(request, location): @@ -166,7 +167,7 @@ def edit_unit(request, location): lms_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format( lms_base=settings.LMS_BASE, # TODO: These will need to be changed to point to the particular instance of this problem in the particular course - course_id= modulestore().get_containing_courses(item.location)[0].id, + course_id = modulestore().get_containing_courses(item.location)[0].id, location=item.location, ) else: @@ -188,10 +189,22 @@ def edit_unit(request, location): in item.get_children() ] + # TODO (cpennington): If we share units between courses, + # this will need to change to check permissions correctly so as + # to pick the correct parent subsection + containing_subsection_locs = modulestore().get_parent_locations(location) + containing_subsection = modulestore().get_item(containing_subsection_locs[0]) + + containing_section_locs = modulestore().get_parent_locations(containing_subsection.location) + containing_section = modulestore().get_item(containing_section_locs[0]) + return render_to_response('unit.html', { 'unit': item, 'components': components, 'component_templates': component_templates, + 'lms_link': lms_link, + 'subsection': containing_subsection, + 'section': containing_section, }) diff --git a/cms/static/sass/_cms_mixins.scss b/cms/static/sass/_cms_mixins.scss index 2f0309a451..e87e90a246 100644 --- a/cms/static/sass/_cms_mixins.scss +++ b/cms/static/sass/_cms_mixins.scss @@ -194,4 +194,4 @@ margin-left: 96px; } } -} \ No newline at end of file +} diff --git a/cms/templates/unit.html b/cms/templates/unit.html index f7264d25a9..ff20f089c9 100644 --- a/cms/templates/unit.html +++ b/cms/templates/unit.html @@ -1,5 +1,6 @@ <%inherit file="base.html" /> <%! from django.core.urlresolvers import reverse %> +<%namespace name="units" file="widgets/units.html" /> <%block name="bodyclass">unit <%block name="title">CMS Unit <%block name="content"> @@ -73,37 +74,36 @@
Save - Preview + Preview

Unit Location

+ ${units.enum_units(subsection, actions=False, selected=unit.location)} - - +
+ diff --git a/cms/templates/widgets/units.html b/cms/templates/widgets/units.html index 12b0d33039..5bfafd46a0 100644 --- a/cms/templates/widgets/units.html +++ b/cms/templates/widgets/units.html @@ -3,18 +3,28 @@ -<%def name="enum_units(subsection)"> +<%def name="enum_units(subsection, actions=True, selected=None)">
    % for unit in subsection.get_children():
  1. -
    + <% + if unit.location == selected: + selected_class = 'editing' + else: + selected_class = '' + %> +
  2. % endfor