Make course ids and usage ids opaque to LMS and Studio [partial commit]
This commit adds all of cms. These keys are now objects with a limited interface, and the particular internal representation is managed by the data storage layer (the modulestore). For the LMS, there should be no outward-facing changes to the system. The keys are, for now, a change to internal representation only. For Studio, the new serialized form of the keys is used in urls, to allow for further migration in the future. Co-Author: Andy Armstrong <andya@edx.org> Co-Author: Christina Roberts <christina@edx.org> Co-Author: David Baumgold <db@edx.org> Co-Author: Diana Huang <dkh@edx.org> Co-Author: Don Mitchell <dmitchell@edx.org> Co-Author: Julia Hansbrough <julia@edx.org> Co-Author: Nimisha Asthagiri <nasthagiri@edx.org> Co-Author: Sarina Canelake <sarina@edx.org> [LMS-2370]
This commit is contained in:
@@ -20,11 +20,12 @@ define ["jquery", "underscore", "gettext", "xblock/runtime.v1",
|
||||
createItem: (parent, payload, callback=->) ->
|
||||
payload.parent_locator = parent
|
||||
$.postJSON(
|
||||
@model.urlRoot
|
||||
@model.urlRoot + '/'
|
||||
payload
|
||||
(data) =>
|
||||
@model.set(id: data.locator)
|
||||
@$el.data('locator', data.locator)
|
||||
@$el.data('courseKey', data.courseKey)
|
||||
@render()
|
||||
).success(callback)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ require(["domReady", "jquery", "underscore", "js/utils/cancel_on_escape"],
|
||||
'run': run
|
||||
});
|
||||
|
||||
$.postJSON('/course', {
|
||||
$.postJSON('/course/', {
|
||||
'org': org,
|
||||
'number': number,
|
||||
'display_name': display_name,
|
||||
|
||||
@@ -7,7 +7,7 @@ define(['js/utils/module'],
|
||||
});
|
||||
describe('getUpdateUrl ', function () {
|
||||
it('can take no arguments', function () {
|
||||
expect(ModuleUtils.getUpdateUrl()).toBe('/xblock');
|
||||
expect(ModuleUtils.getUpdateUrl()).toBe('/xblock/');
|
||||
});
|
||||
it('appends a locator', function () {
|
||||
expect(ModuleUtils.getUpdateUrl("locator")).toBe('/xblock/locator');
|
||||
|
||||
@@ -3,7 +3,7 @@ define(["coffee/src/views/unit", "js/models/module_info", "js/spec_helpers/creat
|
||||
function (UnitEditView, ModuleModel, create_sinon, NotificationView) {
|
||||
var verifyJSON = function (requests, json) {
|
||||
var request = requests[requests.length - 1];
|
||||
expect(request.url).toEqual("/xblock");
|
||||
expect(request.url).toEqual("/xblock/");
|
||||
expect(request.method).toEqual("POST");
|
||||
// There was a problem with order of returned parameters in strings.
|
||||
// Changed to compare objects instead strings.
|
||||
|
||||
@@ -12,7 +12,7 @@ define([], function () {
|
||||
|
||||
var getUpdateUrl = function (locator) {
|
||||
if (locator === undefined) {
|
||||
return urlRoot;
|
||||
return urlRoot + "/";
|
||||
}
|
||||
else {
|
||||
return urlRoot + "/" + locator;
|
||||
|
||||
@@ -14,7 +14,8 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog, V
|
||||
initialize : function() {
|
||||
var self = this,
|
||||
counter = 0,
|
||||
locator = self.$el.closest('[data-locator]').data('locator');
|
||||
locator = self.$el.closest('[data-locator]').data('locator'),
|
||||
courseKey = self.$el.closest('[data-course-key]').data('course-key');
|
||||
|
||||
this.template = this.loadTemplate('metadata-editor');
|
||||
this.$el.html(this.template({numEntries: this.collection.length}));
|
||||
@@ -23,6 +24,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog, V
|
||||
function (model) {
|
||||
var data = {
|
||||
el: self.$el.find('.metadata_entry')[counter++],
|
||||
courseKey: courseKey,
|
||||
locator: locator,
|
||||
model: model
|
||||
},
|
||||
@@ -528,7 +530,7 @@ function(BaseView, _, MetadataModel, AbstractEditor, FileUpload, UploadDialog, V
|
||||
upload: function (event) {
|
||||
var self = this,
|
||||
target = $(event.currentTarget),
|
||||
url = /assets/ + this.options.locator,
|
||||
url = '/assets/' + this.options.courseKey + '/',
|
||||
model = new FileUpload({
|
||||
title: gettext('Upload File'),
|
||||
}),
|
||||
|
||||
@@ -190,6 +190,7 @@ define(["jquery", "underscore", "gettext", "js/views/modals/base_modal",
|
||||
xblockElement = xblockWrapperElement.find('.xblock');
|
||||
xblockInfo = new XBlockInfo({
|
||||
id: xblockWrapperElement.data('locator'),
|
||||
courseKey: xblockWrapperElement.data('course-key'),
|
||||
category: xblockElement.data('block-type')
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user