Make courseware licenses show up in Studio XBlock previews
This commit is contained in:
committed by
Sarina Canelake
parent
648e8a20f7
commit
8fbaa66d33
@@ -17,6 +17,7 @@ from xmodule.exceptions import NotFoundError, ProcessingError
|
||||
from xmodule.library_tools import LibraryToolsService
|
||||
from xmodule.services import SettingsService
|
||||
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.locator import LibraryUsageLocator
|
||||
from xmodule.x_module import ModuleSystem
|
||||
@@ -170,6 +171,10 @@ def _preview_module_system(request, descriptor, field_data):
|
||||
_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
|
||||
|
||||
return PreviewModuleSystem(
|
||||
|
||||
@@ -553,11 +553,6 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
});
|
||||
|
||||
Metadata.License = AbstractEditor.extend({
|
||||
template: _.template(
|
||||
'<label class="label setting-label" for="list-license-types">' +
|
||||
'<%- model.display_name %>' +
|
||||
'</label>'
|
||||
),
|
||||
|
||||
initialize: function(options) {
|
||||
this.licenseModel = new LicenseModel({"asString": this.model.getValue()});
|
||||
@@ -569,13 +564,9 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog,
|
||||
},
|
||||
|
||||
render: function() {
|
||||
this.licenseView.render().$el.css("display", "inline");
|
||||
this.licenseView.undelegateEvents();
|
||||
this.$el.html(this.template({
|
||||
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)
|
||||
this.$el.empty().append(this.licenseView.el);
|
||||
// restore event bindings
|
||||
this.licenseView.delegateEvents();
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user