Commit 55d6aff4 by Calen Pennington

Wire up the unit location display

parent 2412885e
......@@ -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,
})
......
......@@ -194,4 +194,4 @@
margin-left: 96px;
}
}
}
\ No newline at end of file
}
<%inherit file="base.html" />
<%! from django.core.urlresolvers import reverse %>
<%namespace name="units" file="widgets/units.html" />
<%block name="bodyclass">unit</%block>
<%block name="title">CMS Unit</%block>
<%block name="content">
......@@ -73,37 +74,36 @@
</div>
<div class="row unit-actions">
<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 class="window unit-location">
<h4>Unit Location</h4>
<div class="window-contents">
<div><input type="text" class="url" value="/courseware/Week_1/My_Unit" disabled /></div>
<ol>
<li>
<a href="#" class="section-item">Week 1</a>
<div><input type="text" class="url" value="/courseware/${section.url_name}/${subsection.url_name}" disabled /></div>
<section class="courseware-section branch">
<header>
<div class="item-details">
<h3>${section.display_name}</h3>
</div>
</header>
<div class="unit-list">
<ol>
<li>
<a href="#" class="section-item"><span class="folder-icon"></span>Administrivia and Circuit Elements</a>
<ol>
<li><a href="#" class="section-item"><span class="file-icon"></span>Motiviation for 6.002</a></li>
<li><a href="#" class="section-item"><span class="file-icon"></span>Administrivia</a></li>
<li><a href="#" class="section-item"><span class="file-icon"></span>Course Overview</a></li>
<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
<li class="branch">
<div class="section-item">
<div>
<a href="${reverse('edit_subsection', args=[subsection.location])}">
<span class="folder-icon"></span>
<span class="subsection-name"><span class="subsection-name-value">${subsection.display_name}</span></span>
</a>
</li>
</ol>
</div>
</div>
${units.enum_units(subsection, actions=False, selected=unit.location)}
</li>
</ol>
</li>
</ol>
</div>
</section>
</div>
</div>
</div>
......
......@@ -3,18 +3,28 @@
<!--
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>
% for unit in subsection.get_children():
<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">
<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>
% if 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="#" class="drag-handle wip"></a>
</div>
% endif
</div>
</li>
% 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