Commit 8fbaa66d by David Baumgold Committed by Sarina Canelake

Make courseware licenses show up in Studio XBlock previews

parent 648e8a20
...@@ -17,6 +17,7 @@ from xmodule.exceptions import NotFoundError, ProcessingError ...@@ -17,6 +17,7 @@ from xmodule.exceptions import NotFoundError, ProcessingError
from xmodule.library_tools import LibraryToolsService from xmodule.library_tools import LibraryToolsService
from xmodule.services import SettingsService from xmodule.services import SettingsService
from xmodule.modulestore.django import modulestore, ModuleI18nService from xmodule.modulestore.django import modulestore, ModuleI18nService
from xmodule.mixin import wrap_with_license
from opaque_keys.edx.keys import UsageKey from opaque_keys.edx.keys import UsageKey
from opaque_keys.edx.locator import LibraryUsageLocator from opaque_keys.edx.locator import LibraryUsageLocator
from xmodule.x_module import ModuleSystem from xmodule.x_module import ModuleSystem
...@@ -170,6 +171,10 @@ def _preview_module_system(request, descriptor, field_data): ...@@ -170,6 +171,10 @@ def _preview_module_system(request, descriptor, field_data):
_studio_wrap_xblock, _studio_wrap_xblock,
] ]
if settings.FEATURES.get("LICENSING", False):
# stick the license wrapper in front
wrappers.insert(0, wrap_with_license)
descriptor.runtime._services['studio_user_permissions'] = StudioPermissionsService(request) # pylint: disable=protected-access descriptor.runtime._services['studio_user_permissions'] = StudioPermissionsService(request) # pylint: disable=protected-access
return PreviewModuleSystem( return PreviewModuleSystem(
......
...@@ -553,11 +553,6 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog, ...@@ -553,11 +553,6 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
}); });
Metadata.License = AbstractEditor.extend({ Metadata.License = AbstractEditor.extend({
template: _.template(
'<label class="label setting-label" for="list-license-types">' +
'<%- model.display_name %>' +
'</label>'
),
initialize: function(options) { initialize: function(options) {
this.licenseModel = new LicenseModel({"asString": this.model.getValue()}); this.licenseModel = new LicenseModel({"asString": this.model.getValue()});
...@@ -569,13 +564,9 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog, ...@@ -569,13 +564,9 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
}, },
render: function() { render: function() {
this.licenseView.render().$el.css("display", "inline");
this.licenseView.undelegateEvents(); this.licenseView.undelegateEvents();
this.$el.html(this.template({ this.$el.empty().append(this.licenseView.el);
model: this.model.attributes
}));
// make the licenseView display after this template, inline
this.licenseView.render().$el.css("display", "inline")
this.$el.append(this.licenseView.el)
// restore event bindings // restore event bindings
this.licenseView.delegateEvents(); this.licenseView.delegateEvents();
return this; return this;
......
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