diff --git a/cms/djangoapps/contentstore/views.py b/cms/djangoapps/contentstore/views.py
index f3d1f47ecf..931ead4027 100644
--- a/cms/djangoapps/contentstore/views.py
+++ b/cms/djangoapps/contentstore/views.py
@@ -118,7 +118,7 @@ def course_index(request, org, course, name):
@login_required
-def edit_item(request):
+def edit_item(request, location):
"""
Display an editing page for the specified module.
@@ -127,11 +127,10 @@ def edit_item(request):
id: A Location URL
"""
# TODO (vshnayder): change name from id to location in coffee+html as well.
- item_location = request.GET['id']
- if not has_access(request.user, item_location):
+ if not has_access(request.user, location):
raise Http404 # TODO (vshnayder): better error
- item = modulestore().get_item(item_location)
+ item = modulestore().get_item(location)
item.get_html = wrap_xmodule(item.get_html, item, "xmodule_edit.html")
if settings.LMS_BASE is not None:
@@ -146,17 +145,16 @@ def edit_item(request):
return render_to_response('unit.html', {
- 'contents': item.get_html(),
- 'js_module': item.js_module_name,
- 'category': item.category,
- 'url_name': item.url_name,
- 'previews': get_module_previews(request, item),
- 'metadata': item.metadata,
- # TODO: It would be nice to able to use reverse here in some form, but we don't have the lms urls imported
- 'lms_link': lms_link,
+ 'module': item,
+ 'editable_preview': get_module_previews(request, item)[0],
})
+@login_required
+def delete_item(request, location):
+ pass
+
+
@login_required
def new_item(request):
"""
@@ -277,6 +275,7 @@ def preview_module_system(request, preview_id, descriptor):
preview_id (str): An identifier specifying which preview this module is used for
descriptor: An XModuleDescriptor
"""
+
return ModuleSystem(
ajax_url=reverse('preview_dispatch', args=[preview_id, descriptor.location.url(), '']).rstrip('/'),
# TODO (cpennington): Do we want to track how instructors are using the preview problems?
@@ -323,8 +322,10 @@ def load_preview_module(request, preview_id, descriptor, instance_state, shared_
error_msg=exc_info_to_str(sys.exc_info())
).xmodule_constructor(system)(None, None)
+ module.get_html = wrap_xmodule(module.get_html, module, "xmodule_display.html")
+ module.get_html = wrap_xmodule(module.get_html, module, "editable_preview.html")
module.get_html = replace_static_urls(
- wrap_xmodule(module.get_html, module, "xmodule_display.html"),
+ module.get_html,
module.metadata.get('data_dir', module.location.course)
)
save_preview_state(request, preview_id, descriptor.location.url(),
diff --git a/cms/static/js/base.js b/cms/static/js/base.js
index bf8c845f57..5042830364 100644
--- a/cms/static/js/base.js
+++ b/cms/static/js/base.js
@@ -6,160 +6,162 @@ var $newComponentStep1;
var $newComponentStep2;
$(document).ready(function() {
- $body = $('body');
- $modal = $('.history-modal');
- $modalCover = $('.modal-cover');
- $newComponentItem = $('.new-component-item');
- $newComponentStep1 = $('.new-component-step-1');
- $newComponentStep2 = $('.new-component-step-2');
- $newComponentButton = $('.new-component-button');
+ $body = $('body');
+ $modal = $('.history-modal');
+ $modalCover = $('.modal-cover');
+ $newComponentItem = $('.new-component-item');
+ $newComponentStep1 = $('.new-component-step-1');
+ $newComponentStep2 = $('.new-component-step-2');
+ $newComponentButton = $('.new-component-button');
- $('.expand-collapse-icon').bind('click', toggleSubmodules);
- $('.visibility-options').bind('change', setVisibility);
+ $('.expand-collapse-icon').bind('click', toggleSubmodules);
+ $('.visibility-options').bind('change', setVisibility);
- $body.delegate('.components .edit-button', 'click', editComponent);
- $body.delegate('.component-editor .save-button, .component-editor .cancel-button', 'click', closeComponentEditor);
+ $body.delegate('.components .edit-button', 'click', editComponent);
+ $body.delegate('.component-editor .save-button, .component-editor .cancel-button', 'click', closeComponentEditor);
- $newComponentButton.bind('click', showNewComponentForm);
- $newComponentStep1.find('.new-component-type a').bind('click', showNewComponentProperties);
- $newComponentStep2.find('.save-button').bind('click', saveNewComponent);
- $newComponentStep2.find('.cancel-button').bind('click', cancelNewComponent);
+ $newComponentButton.bind('click', showNewComponentForm);
+ $newComponentStep1.find('.new-component-type a').bind('click', showNewComponentProperties);
+ $newComponentStep2.find('.save-button').bind('click', saveNewComponent);
+ $newComponentStep2.find('.cancel-button').bind('click', cancelNewComponent);
- $('.unit-history ol a').bind('click', showHistoryModal);
- $modal.bind('click', hideHistoryModal);
- $modalCover.bind('click', hideHistoryModal);
+ $('.unit-history ol a').bind('click', showHistoryModal);
+ $modal.bind('click', hideHistoryModal);
+ $modalCover.bind('click', hideHistoryModal);
+
+ XModule.loadModules('display');
});
function toggleSubmodules(e) {
- e.preventDefault();
- $(this).toggleClass('expand').toggleClass('collapse');
- $(this).closest('.branch, .window').toggleClass('collapsed');
+ e.preventDefault();
+ $(this).toggleClass('expand').toggleClass('collapse');
+ $(this).closest('.branch, .window').toggleClass('collapsed');
}
function setVisibility(e) {
- $(this).find('.checked').removeClass('checked');
- $(e.target).closest('.option').addClass('checked');
+ $(this).find('.checked').removeClass('checked');
+ $(e.target).closest('.option').addClass('checked');
}
function editComponent(e) {
- e.preventDefault();
- $(this).closest('li').addClass('editing').find('.component-editor').slideDown(150);
+ e.preventDefault();
+ $(this).closest('li').addClass('editing').find('.component-editor').slideDown(150);
}
function closeComponentEditor(e) {
- e.preventDefault();
- $(this).closest('li').removeClass('editing').find('.component-editor').slideUp(150);
+ e.preventDefault();
+ $(this).closest('li').removeClass('editing').find('.component-editor').slideUp(150);
}
function showNewComponentForm(e) {
- e.preventDefault();
- $newComponentItem.addClass('adding');
- $(this).slideUp(150);
- $newComponentStep1.slideDown(150);
+ e.preventDefault();
+ $newComponentItem.addClass('adding');
+ $(this).slideUp(150);
+ $newComponentStep1.slideDown(150);
}
function showNewComponentProperties(e) {
- e.preventDefault();
+ e.preventDefault();
- var displayName;
- var componentSource;
- var selectionRange;
- var $renderedComponent;
+ var displayName;
+ var componentSource;
+ var selectionRange;
+ var $renderedComponent;
- switch($(this).attr('data-type')) {
- case 'video':
- displayName = 'Video';
- componentSource = '';
- selectionRange = [21, 24];
- $renderedComponent = $('
');
- break;
- case 'textbook':
- displayName = 'Textbook';
- componentSource = 'book';
- selectionRange = [17, 20];
- $renderedComponent = $('More information given in the text.
');
- break;
- case 'slide':
- displayName = 'Slide';
- componentSource = 'slides';
- selectionRange = [17, 20];
- $renderedComponent = $('Lecture Slides Handout [Clean] [Annotated]
');
- break;
- case 'discussion':
- displayName = 'Discussion';
- componentSource = '';
- selectionRange = [17, 20];
- $renderedComponent = $('');
- break;
- case 'problem':
- displayName = 'Problem';
- componentSource = '___';
- selectionRange = [9, 12];
- $renderedComponent = $('');
- break;
- case 'freeform':
- displayName = 'Freeform HTML';
- componentSource = '';
- selectionRange = [0, 0];
- $renderedComponent = $('');
- break;
- }
+ switch($(this).attr('data-type')) {
+ case 'video':
+ displayName = 'Video';
+ componentSource = '';
+ selectionRange = [21, 24];
+ $renderedComponent = $('');
+ break;
+ case 'textbook':
+ displayName = 'Textbook';
+ componentSource = 'book';
+ selectionRange = [17, 20];
+ $renderedComponent = $('More information given in the text.
');
+ break;
+ case 'slide':
+ displayName = 'Slide';
+ componentSource = 'slides';
+ selectionRange = [17, 20];
+ $renderedComponent = $('Lecture Slides Handout [Clean] [Annotated]
');
+ break;
+ case 'discussion':
+ displayName = 'Discussion';
+ componentSource = '';
+ selectionRange = [17, 20];
+ $renderedComponent = $('');
+ break;
+ case 'problem':
+ displayName = 'Problem';
+ componentSource = '___';
+ selectionRange = [9, 12];
+ $renderedComponent = $('');
+ break;
+ case 'freeform':
+ displayName = 'Freeform HTML';
+ componentSource = '';
+ selectionRange = [0, 0];
+ $renderedComponent = $('');
+ break;
+ }
- $newComponentItem.prepend($renderedComponent);
- $renderedComponent.slideDown(250);
+ $newComponentItem.prepend($renderedComponent);
+ $renderedComponent.slideDown(250);
- $newComponentStep2.find('h5').html('Edit ' + displayName + ' Component');
- $newComponentStep2.find('textarea').html(componentSource);
- setTimeout(function() {
- $newComponentStep2.find('textarea').focus().get(0).setSelectionRange(selectionRange[0], selectionRange[1]);
- }, 10);
+ $newComponentStep2.find('h5').html('Edit ' + displayName + ' Component');
+ $newComponentStep2.find('textarea').html(componentSource);
+ setTimeout(function() {
+ $newComponentStep2.find('textarea').focus().get(0).setSelectionRange(selectionRange[0], selectionRange[1]);
+ }, 10);
- $newComponentStep1.slideUp(250);
- $newComponentStep2.slideDown(250);
+ $newComponentStep1.slideUp(250);
+ $newComponentStep2.slideDown(250);
}
function cancelNewComponent(e) {
- e.preventDefault();
+ e.preventDefault();
- $newComponentStep2.slideUp(250);
- $newComponentButton.slideDown(250);
- $newComponentItem.removeClass('adding');
- $newComponentItem.find('.rendered-component').remove();
+ $newComponentStep2.slideUp(250);
+ $newComponentButton.slideDown(250);
+ $newComponentItem.removeClass('adding');
+ $newComponentItem.find('.rendered-component').remove();
}
function saveNewComponent(e) {
- e.preventDefault();
+ e.preventDefault();
- var $newComponent = $newComponentItem.clone();
- $newComponent.removeClass('adding').removeClass('new-component-item');
- $newComponent.find('.new-component-step-2').removeClass('new-component-step-2').addClass('component-editor');
- setTimeout(function() {
- $newComponent.find('.component-editor').slideUp(250);
- }, 10);
- $newComponent.append('');
- $newComponent.find('.new-component-step-1').remove();
- $newComponent.find('.new-component-button').remove();
+ var $newComponent = $newComponentItem.clone();
+ $newComponent.removeClass('adding').removeClass('new-component-item');
+ $newComponent.find('.new-component-step-2').removeClass('new-component-step-2').addClass('component-editor');
+ setTimeout(function() {
+ $newComponent.find('.component-editor').slideUp(250);
+ }, 10);
+ $newComponent.append('');
+ $newComponent.find('.new-component-step-1').remove();
+ $newComponent.find('.new-component-button').remove();
- $newComponentStep2.slideUp(250);
- $newComponentButton.slideDown(250);
- $newComponentItem.removeClass('adding');
- $newComponentItem.find('.rendered-component').remove();
+ $newComponentStep2.slideUp(250);
+ $newComponentButton.slideDown(250);
+ $newComponentItem.removeClass('adding');
+ $newComponentItem.find('.rendered-component').remove();
- $newComponentItem.before($newComponent);
+ $newComponentItem.before($newComponent);
}
function showHistoryModal(e) {
- e.preventDefault();
+ e.preventDefault();
- $modal.show();
- $modalCover.show();
+ $modal.show();
+ $modalCover.show();
}
function hideHistoryModal(e) {
- e.preventDefault();
+ e.preventDefault();
- $modal.hide();
- $modalCover.hide();
+ $modal.hide();
+ $modalCover.hide();
}
diff --git a/cms/templates/editable_preview.html b/cms/templates/editable_preview.html
new file mode 100644
index 0000000000..16fca59e14
--- /dev/null
+++ b/cms/templates/editable_preview.html
@@ -0,0 +1,13 @@
+
+${content}
+
+
+
+
diff --git a/cms/templates/overview.html b/cms/templates/overview.html
index a3f31a3613..c9299981aa 100644
--- a/cms/templates/overview.html
+++ b/cms/templates/overview.html
@@ -1,6 +1,6 @@
<%inherit file="base.html" />
+<%! from django.core.urlresolvers import reverse %>
<%block name="title">CMS Courseware Overview%block>
-<%include file="widgets/header.html"/>
<%def name="branch(section)">
@@ -11,54 +11,62 @@
${section.display_name} – draft
-
+ ${actions(section)}
% for unit in section.get_children():
${branch(unit)}
% endfor
+ ${new_unit()}
%def>
+<%def name="actions(unit)">
+
+%def>
+
+<%def name="new_unit()">
+
+
+ New Unit
+
+
+%def>
+
<%block name="content">
-
-
-
Courseware
-
-
- New Section
- % for week in weeks:
-
-
-
-
-
${week.display_name}
-
-
-
-
-
- % for section in week.get_children():
- ${branch(section)}
- % endfor
-
-
- % endfor
-
-
+
+
+
Courseware
+
+
+ New Section
+ % for week in weeks:
+
+
+
+
+
${week.display_name}
+
+
+ ${actions(week)}
+
+
+ % for section in week.get_children():
+ ${branch(section)}
+ % endfor
+ ${new_unit()}
+
+
+ % endfor
+
-
<%include file="widgets/upload_assets.html"/>
-
-
+
+
%block>
diff --git a/cms/templates/unit.html b/cms/templates/unit.html
index 0db507f897..34c890000a 100644
--- a/cms/templates/unit.html
+++ b/cms/templates/unit.html
@@ -1,61 +1,60 @@
-
-
-
+<%inherit file="base.html" />
+<%! from django.core.urlresolvers import reverse %>
+<%block name="title">CMS Unit%block>
+<%block name="content">
+
+
+
+
+ ${editable_preview}
+
-
-
+
-
-
- ${contents}
- % if lms_link is not None:
- View in LMS
- % endif
-
- % for preview in previews:
-
- % endfor
-
-
-
Save & Update
-
Cancel
+
+
+
S3V2: Properties of Linearity
+
+
More information given in the text.
+
Lecture Slides Handout [Clean] [Annotated]
- <%include file="widgets/notes.html"/>
-
-
+
+
+
+
+%block>
diff --git a/cms/urls.py b/cms/urls.py
index ddd54adc65..2a717085d1 100644
--- a/cms/urls.py
+++ b/cms/urls.py
@@ -10,7 +10,8 @@ import django.contrib.auth.views
urlpatterns = ('',
url(r'^$', 'contentstore.views.index', name='index'),
url(r'^new_item$', 'contentstore.views.new_item', name='new_item'),
- url(r'^edit_item$', 'contentstore.views.edit_item', name='edit_item'),
+ url(r'^edit/(?P
.*?)$', 'contentstore.views.edit_item', name='edit_item'),
+ url(r'^delete/(?P.*?)$', 'contentstore.views.delete_item', name='delete_item'),
url(r'^save_item$', 'contentstore.views.save_item', name='save_item'),
url(r'^clone_item$', 'contentstore.views.clone_item', name='clone_item'),
url(r'^(?P[^/]+)/(?P[^/]+)/course/(?P[^/]+)$',