Move notebook.rename to contentmanager

Make notebook.rename call contentmanager.rename
This commit is contained in:
Jeff Hemmelgarn 2014-07-20 15:10:35 -04:00 committed by Thomas Kluyver
parent 7043aa1b9e
commit 5b5e194082
2 changed files with 8 additions and 31 deletions

View File

@ -103,16 +103,16 @@ define([
type : "PATCH",
data : JSON.stringify(data),
dataType: "json",
headers : {'Content-Type': 'application/json'},
success : $.proxy(that.rename_success, this),
error : $.proxy(that.rename_error, this)
contentType: 'application/json',
success : $.proxy(that.rename_success, that),
error : $.proxy(that.rename_error, that)
};
this.events.trigger('rename_notebook.Notebook', data);
var url = utils.url_join_encode(
this.base_url,
that.base_url,
'api/notebooks',
this.notebook_path,
this.notebook_name
that.notebook_path,
that.notebook_name
);
$.ajax(url, settings);
};
@ -133,7 +133,7 @@ define([
cache : false,
type : "PUT",
data : JSON.stringify(model),
headers : {'Content-Type': 'application/json'},
contentType: 'application/json',
success : $.proxy(notebook.save_notebook_success, this, start),
error : $.proxy(notebook.save_notebook_error, this)
};

View File

@ -2095,36 +2095,13 @@ define([
};
Notebook.prototype.rename = function (nbname) {
var that = this;
if (!nbname.match(/\.ipynb$/)) {
nbname = nbname + ".ipynb";
}
var data = {name: nbname};
var settings = {
processData : false,
cache : false,
type : "PATCH",
data : JSON.stringify(data),
dataType: "json",
contentType: 'application/json',
success : $.proxy(that.rename_success, this),
error : $.proxy(that.rename_error, this)
};
this.events.trigger('rename_notebook.Notebook', data);
var url = utils.url_join_encode(
this.base_url,
'api/contents',
this.notebook_path,
this.notebook_name
);
$.ajax(url, settings);
this.content_manager.rename_notebook(this, nbname);
};
Notebook.prototype.delete = function () {
this.content_manager.delete_notebook(this.notebook_name, this.notebook_path, this.base_url);
};
Notebook.prototype.rename_success = function (json, status, xhr) {
var name = this.notebook_name = json.name;
var path = json.path;