Merge pull request #816 from MITx/feature/cdodge/subsection-edit-page
Feature/cdodge/subsection edit page
This commit is contained in:
@@ -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)
|
||||
|
||||
65
cms/templates/edit_subsection.html
Normal file
65
cms/templates/edit_subsection.html
Normal file
@@ -0,0 +1,65 @@
|
||||
<%inherit file="base.html" />
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
<%block name="bodyclass">subsection</%block>
|
||||
<%block name="title">CMS Subsection</%block>
|
||||
|
||||
<%namespace name="units" file="widgets/units.html" />
|
||||
|
||||
<%block name="content">
|
||||
<div class="main-wrapper">
|
||||
<div class="inner-wrapper">
|
||||
<div class="main-column">
|
||||
<article class="subsection-body window">
|
||||
<div class="subsection-name-input">
|
||||
<label>Display Name:</label>
|
||||
<input type="text" value="Welcome to 6.002x" class="subsection-display-name-input" />
|
||||
</div>
|
||||
<div>
|
||||
<label>Subtitle:</label>
|
||||
<input type="text" value="Lecture Sequence" class="unit-subtitle" />
|
||||
</div>
|
||||
<div class="unit-list">
|
||||
<label>Units:</label>
|
||||
${units.enum_units(subsection)}
|
||||
</div>
|
||||
<div>
|
||||
<label>Policy:</label>
|
||||
<textarea class="text-editor">Policy blah, blah, blah…</textarea>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
|
||||
<div class="sidebar">
|
||||
<div class="unit-properties window">
|
||||
<h4>Subsection Settings</h4>
|
||||
<div class="window-contents">
|
||||
<div class="scheduled-date-input row">
|
||||
<label>Release date:<!-- <span class="description">Determines when this subsection and the units within it will be released publicly.</span>--></label>
|
||||
<div class="date-setter">
|
||||
<input type="text" value="10/22/2012" class="date-input" />
|
||||
<input type="text" value="6:00 am" class="time-input" />
|
||||
</div>
|
||||
<p class="notice">The date above differs from the release date of Week 1 – 10/10/2012 at 12:00 am. <a href="#" class="sync-date">Sync to Week 1.</a></p>
|
||||
</div>
|
||||
<div class="due-date-input row">
|
||||
<label>Due date:</label>
|
||||
<a href="#" class="set-date">Set a due date</a>
|
||||
<div class="date-setter">
|
||||
<p class="date-description"><input type="text" value="10/20/2012" class="date-input" /> <input type="text" value="6:00 am" class="time-input" />
|
||||
<a href="#" class="remove-date">Remove due date</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="visibility row">
|
||||
<label>Visibility:<!-- <span class="description">Shows or hides this subsection and the units within it.</span>--></label>
|
||||
<a href="#" class="toggle-off">hide</a><a href="#" class="large-toggle"></a><a href="#" class="toggle-on">show</a>
|
||||
</div>
|
||||
<div class="row unit-actions">
|
||||
<a href="#" class="save-button">Save</a>
|
||||
<a href="preview.html" target="_blank" class="preview-button">Preview</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</%block>
|
||||
@@ -2,6 +2,9 @@
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
<%block name="title">CMS Courseware Overview</%block>
|
||||
|
||||
<%namespace name="units" file="widgets/units.html" />
|
||||
|
||||
|
||||
<%block name="content">
|
||||
<div class="main-wrapper">
|
||||
<div class="inner-wrapper">
|
||||
@@ -34,7 +37,7 @@
|
||||
<div class="section-item">
|
||||
<div>
|
||||
<a href="#" class="expand-collapse-icon expand"></a>
|
||||
<a href="#">
|
||||
<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>
|
||||
@@ -44,27 +47,7 @@
|
||||
<a href="#" class="drag-handle wip"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ol>
|
||||
% for unit in subsection.get_children():
|
||||
<li class="leaf">
|
||||
<div class="section-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>
|
||||
</a>
|
||||
<div class="item-actions">
|
||||
<a href="${reverse('delete_unit', args=[unit.location])}" class="edit-button wip"><span class="delete-icon"></span></a>
|
||||
<a href="#" class="drag-handle wip"></a>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
% endfor
|
||||
<li>
|
||||
<a href="#" class="new-unit-item wip">
|
||||
<span class="new-unit-icon"></span>New Unit
|
||||
</a>
|
||||
</li>
|
||||
</ol>
|
||||
${units.enum_units(subsection)}
|
||||
</li>
|
||||
% endfor
|
||||
</ol>
|
||||
|
||||
27
cms/templates/widgets/units.html
Normal file
27
cms/templates/widgets/units.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<%! from django.core.urlresolvers import reverse %>
|
||||
|
||||
<!--
|
||||
This def will enumerate through a passed in subsection and list all of the units
|
||||
-->
|
||||
<%def name="enum_units(subsection)">
|
||||
<ol>
|
||||
% for unit in subsection.get_children():
|
||||
<li class="leaf">
|
||||
<div class="section-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>
|
||||
</a>
|
||||
<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>
|
||||
</div>
|
||||
</li>
|
||||
% endfor
|
||||
<li>
|
||||
<a href="#" class="new-unit-item wip">
|
||||
<span class="new-unit-icon"></span>New Unit
|
||||
</a>
|
||||
</li>
|
||||
</ol>
|
||||
</%def>
|
||||
@@ -10,6 +10,7 @@ import django.contrib.auth.views
|
||||
urlpatterns = ('',
|
||||
url(r'^$', 'contentstore.views.index', name='index'),
|
||||
url(r'^edit/(?P<location>.*?)$', 'contentstore.views.edit_unit', name='edit_unit'),
|
||||
url(r'^subsection/(?P<location>.*?)$', 'contentstore.views.edit_subsection', name='edit_subsection'),
|
||||
url(r'^delete/(?P<location>.*?)$', 'contentstore.views.delete_unit', name='delete_unit'),
|
||||
url(r'^preview_component/(?P<location>.*?)$', 'contentstore.views.preview_component', name='preview_component'),
|
||||
url(r'^save_item$', 'contentstore.views.save_item', name='save_item'),
|
||||
|
||||
Reference in New Issue
Block a user