use 'id' for checkpoint ID key

rather than redundant checkpoint.checkpoint_id
This commit is contained in:
MinRK 2013-10-17 14:45:25 -07:00
parent 5a60141bed
commit d1a36fe4c0
4 changed files with 12 additions and 12 deletions

View File

@ -278,7 +278,7 @@ class FileNotebookManager(NotebookManager):
# clear checkpoints # clear checkpoints
for checkpoint in self.list_checkpoints(name, path): for checkpoint in self.list_checkpoints(name, path):
checkpoint_id = checkpoint['checkpoint_id'] checkpoint_id = checkpoint['id']
cp_path = self.get_checkpoint_path(checkpoint_id, name, path) cp_path = self.get_checkpoint_path(checkpoint_id, name, path)
if os.path.isfile(cp_path): if os.path.isfile(cp_path):
self.log.debug("Unlinking checkpoint %s", cp_path) self.log.debug("Unlinking checkpoint %s", cp_path)
@ -315,7 +315,7 @@ class FileNotebookManager(NotebookManager):
# Move the checkpoints # Move the checkpoints
old_checkpoints = self.list_checkpoints(old_name, old_path) old_checkpoints = self.list_checkpoints(old_name, old_path)
for cp in old_checkpoints: for cp in old_checkpoints:
checkpoint_id = cp['checkpoint_id'] checkpoint_id = cp['id']
old_cp_path = self.get_checkpoint_path(checkpoint_id, old_name, old_path) old_cp_path = self.get_checkpoint_path(checkpoint_id, old_name, old_path)
new_cp_path = self.get_checkpoint_path(checkpoint_id, new_name, new_path) new_cp_path = self.get_checkpoint_path(checkpoint_id, new_name, new_path)
if os.path.isfile(old_cp_path): if os.path.isfile(old_cp_path):
@ -346,7 +346,7 @@ class FileNotebookManager(NotebookManager):
stats = os.stat(cp_path) stats = os.stat(cp_path)
last_modified = tz.utcfromtimestamp(stats.st_mtime) last_modified = tz.utcfromtimestamp(stats.st_mtime)
info = dict( info = dict(
checkpoint_id = checkpoint_id, id = checkpoint_id,
last_modified = last_modified, last_modified = last_modified,
) )
return info return info

View File

@ -180,9 +180,9 @@ class NotebookCheckpointsHandler(IPythonHandler):
nbm = self.notebook_manager nbm = self.notebook_manager
checkpoint = nbm.create_checkpoint(name, path) checkpoint = nbm.create_checkpoint(name, path)
data = json.dumps(checkpoint, default=date_default) data = json.dumps(checkpoint, default=date_default)
location = url_path_join(self.base_project_url, u'/api/notebooks', location = url_path_join(self.base_project_url, 'api/notebooks',
path, name, 'checkpoints', checkpoint[u'checkpoint_id']) path, name, 'checkpoints', checkpoint['id'])
self.set_header(u'Location', location) self.set_header('Location', location)
self.set_status(201) self.set_status(201)
self.finish(data) self.finish(data)

View File

@ -229,8 +229,8 @@ class APITest(NotebookTestBase):
r = self.nb_api.new_checkpoint('a.ipynb', 'foo') r = self.nb_api.new_checkpoint('a.ipynb', 'foo')
self.assertEqual(r.status_code, 201) self.assertEqual(r.status_code, 201)
cp1 = r.json() cp1 = r.json()
self.assertEqual(set(cp1), {'checkpoint_id', 'last_modified'}) self.assertEqual(set(cp1), {'id', 'last_modified'})
self.assertEqual(r.headers['Location'].split('/')[-1], cp1['checkpoint_id']) self.assertEqual(r.headers['Location'].split('/')[-1], cp1['id'])
# Modify it # Modify it
nbcontent = jsonapi.loads(resp.text)['content'] nbcontent = jsonapi.loads(resp.text)['content']
@ -252,14 +252,14 @@ class APITest(NotebookTestBase):
self.assertEqual(nb.worksheets[0].cells[0].source, 'Created by test') self.assertEqual(nb.worksheets[0].cells[0].source, 'Created by test')
# Restore cp1 # Restore cp1
r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1['checkpoint_id']) r = self.nb_api.restore_checkpoint('a.ipynb', 'foo', cp1['id'])
self.assertEqual(r.status_code, 204) self.assertEqual(r.status_code, 204)
nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content'] nbcontent = self.nb_api.read('a.ipynb', 'foo').json()['content']
nb = to_notebook_json(nbcontent) nb = to_notebook_json(nbcontent)
self.assertEqual(nb.worksheets, []) self.assertEqual(nb.worksheets, [])
# Delete cp1 # Delete cp1
r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1['checkpoint_id']) r = self.nb_api.delete_checkpoint('a.ipynb', 'foo', cp1['id'])
self.assertEqual(r.status_code, 204) self.assertEqual(r.status_code, 204)
cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json() cps = self.nb_api.get_checkpoints('a.ipynb', 'foo').json()
self.assertEqual(cps, []) self.assertEqual(cps, [])

View File

@ -2009,7 +2009,7 @@ var IPython = (function (IPython) {
var found = false; var found = false;
for (var i = 0; i < this.checkpoints.length; i++) { for (var i = 0; i < this.checkpoints.length; i++) {
var existing = this.checkpoints[i]; var existing = this.checkpoints[i];
if (existing.checkpoint_id == checkpoint.checkpoint_id) { if (existing.id == checkpoint.id) {
found = true; found = true;
this.checkpoints[i] = checkpoint; this.checkpoints[i] = checkpoint;
break; break;
@ -2149,7 +2149,7 @@ var IPython = (function (IPython) {
Revert : { Revert : {
class : "btn-danger", class : "btn-danger",
click : function () { click : function () {
that.restore_checkpoint(checkpoint.checkpoint_id); that.restore_checkpoint(checkpoint.id);
} }
}, },
Cancel : {} Cancel : {}