Commit 55d6aff4 by Calen Pennington

Wire up the unit location display

parent 2412885e
...@@ -144,8 +144,9 @@ def edit_subsection(request, location): ...@@ -144,8 +144,9 @@ def edit_subsection(request, location):
if item.location.category != 'sequential': if item.location.category != 'sequential':
return HttpResponseBadRequest return HttpResponseBadRequest
return render_to_response('edit_subsection.html', return render_to_response('edit_subsection.html',
{'subsection':item}) {'subsection': item})
@login_required @login_required
def edit_unit(request, location): def edit_unit(request, location):
...@@ -166,7 +167,7 @@ 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_link = "{lms_base}/courses/{course_id}/jump_to/{location}".format(
lms_base=settings.LMS_BASE, 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 # 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, location=item.location,
) )
else: else:
...@@ -188,10 +189,22 @@ def edit_unit(request, location): ...@@ -188,10 +189,22 @@ def edit_unit(request, location):
in item.get_children() 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', { return render_to_response('unit.html', {
'unit': item, 'unit': item,
'components': components, 'components': components,
'component_templates': component_templates, 'component_templates': component_templates,
'lms_link': lms_link,
'subsection': containing_subsection,
'section': containing_section,
}) })
......
...@@ -194,4 +194,4 @@ ...@@ -194,4 +194,4 @@
margin-left: 96px; margin-left: 96px;
} }
} }
} }
\ No newline at end of file
<%inherit file="base.html" /> <%inherit file="base.html" />
<%! from django.core.urlresolvers import reverse %> <%! from django.core.urlresolvers import reverse %>
<%namespace name="units" file="widgets/units.html" />
<%block name="bodyclass">unit</%block> <%block name="bodyclass">unit</%block>
<%block name="title">CMS Unit</%block> <%block name="title">CMS Unit</%block>
<%block name="content"> <%block name="content">
...@@ -73,37 +74,36 @@ ...@@ -73,37 +74,36 @@
</div> </div>
<div class="row unit-actions"> <div class="row unit-actions">
<a href="#" class="save-button">Save</a> <a href="#" class="save-button">Save</a>
<a href="preview.html" target="_blank" class="preview-button">Preview</a> <a href="${lms_link}" target="_blank" class="preview-button">Preview</a>
</div> </div>
</div> </div>
</div> </div>
<div class="window unit-location"> <div class="window unit-location">
<h4>Unit Location</h4> <h4>Unit Location</h4>
<div class="window-contents"> <div class="window-contents">
<div><input type="text" class="url" value="/courseware/Week_1/My_Unit" disabled /></div> <div><input type="text" class="url" value="/courseware/${section.url_name}/${subsection.url_name}" disabled /></div>
<ol> <section class="courseware-section branch">
<li> <header>
<a href="#" class="section-item">Week 1</a> <div class="item-details">
<h3>${section.display_name}</h3>
</div>
</header>
<div class="unit-list">
<ol> <ol>
<li> <li class="branch">
<a href="#" class="section-item"><span class="folder-icon"></span>Administrivia and Circuit Elements</a> <div class="section-item">
<ol> <div>
<li><a href="#" class="section-item"><span class="file-icon"></span>Motiviation for 6.002</a></li> <a href="${reverse('edit_subsection', args=[subsection.location])}">
<li><a href="#" class="section-item"><span class="file-icon"></span>Administrivia</a></li> <span class="folder-icon"></span>
<li><a href="#" class="section-item"><span class="file-icon"></span>Course Overview</a></li> <span class="subsection-name"><span class="subsection-name-value">${subsection.display_name}</span></span>
<li><a href="#" class="section-item"><span class="file-icon"></span>Lumped Element Abstraction</a></li>
<li><a href="#" class="section-item"><span class="file-icon"></span>Simple Power</a></li>
<li><a href="#" class="current section-item"><span class="file-icon"></span>New Unit</a></li>
<li>
<a href="unit.html" class="new-unit-item">
<span class="new-unit-icon"></span>New Unit
</a> </a>
</li> </div>
</ol> </div>
${units.enum_units(subsection, actions=False, selected=unit.location)}
</li> </li>
</ol> </ol>
</li> </div>
</ol> </section>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -3,18 +3,28 @@ ...@@ -3,18 +3,28 @@
<!-- <!--
This def will enumerate through a passed in subsection and list all of the units This def will enumerate through a passed in subsection and list all of the units
--> -->
<%def name="enum_units(subsection)"> <%def name="enum_units(subsection, actions=True, selected=None)">
<ol> <ol>
% for unit in subsection.get_children(): % for unit in subsection.get_children():
<li class="leaf"> <li class="leaf">
<div class="section-item"> <%
if unit.location == selected:
selected_class = 'editing'
else:
selected_class = ''
%>
<div class="section-item ${selected_class}">
<a href="${reverse('edit_unit', args=[unit.location])}" class="private-item"> <a href="${reverse('edit_unit', args=[unit.location])}" class="private-item">
<span class="${unit.category}-icon"></span>${unit.display_name} <span class="private-tag">- private</span> <span class="${unit.category}-icon"></span>
${unit.display_name}
<span class="private-tag">- private</span>
</a> </a>
% if actions:
<div class="item-actions"> <div class="item-actions">
<a href="${reverse('delete_unit', args=[unit.location])}" classs="edit-button wip"><span class="delete-icon"></span></a> <a href="${reverse('delete_unit', args=[unit.location])}" classs="edit-button wip"><span class="delete-icon"></span></a>
<a href="#" class="drag-handle wip"></a> <a href="#" class="drag-handle wip"></a>
</div> </div>
% endif
</div> </div>
</li> </li>
% endfor % endfor
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment