##// END OF EJS Templates
trust via mark cells and save, rather than trust API request
MinRK -
Show More
@@ -222,17 +222,6 b' class NotebookHandler(IPythonHandler):'
222 self.finish()
222 self.finish()
223
223
224
224
225 class NotebookTrustHandler(IPythonHandler):
226
227 SUPPORTED_METHODS = ('POST')
228
229 @web.authenticated
230 def post(self, path='', name=None):
231 """trust the specified notebook"""
232 self.notebook_manager.trust_notebook(name, path)
233 self.set_status(200)
234
235
236 class NotebookCheckpointsHandler(IPythonHandler):
225 class NotebookCheckpointsHandler(IPythonHandler):
237
226
238 SUPPORTED_METHODS = ('GET', 'POST')
227 SUPPORTED_METHODS = ('GET', 'POST')
@@ -290,7 +279,6 b' class ModifyNotebookCheckpointsHandler(IPythonHandler):'
290 _checkpoint_id_regex = r"(?P<checkpoint_id>[\w-]+)"
279 _checkpoint_id_regex = r"(?P<checkpoint_id>[\w-]+)"
291
280
292 default_handlers = [
281 default_handlers = [
293 (r"/api/notebooks%s/trust" % notebook_path_regex, NotebookTrustHandler),
294 (r"/api/notebooks%s/checkpoints" % notebook_path_regex, NotebookCheckpointsHandler),
282 (r"/api/notebooks%s/checkpoints" % notebook_path_regex, NotebookCheckpointsHandler),
295 (r"/api/notebooks%s/checkpoints/%s" % (notebook_path_regex, _checkpoint_id_regex),
283 (r"/api/notebooks%s/checkpoints/%s" % (notebook_path_regex, _checkpoint_id_regex),
296 ModifyNotebookCheckpointsHandler),
284 ModifyNotebookCheckpointsHandler),
@@ -1637,7 +1637,6 b' var IPython = (function (IPython) {'
1637 }
1637 }
1638 }
1638 }
1639 }
1639 }
1640 console.log('t', trusted, this.trusted);
1641 if (trusted != this.trusted) {
1640 if (trusted != this.trusted) {
1642 this.trusted = trusted;
1641 this.trusted = trusted;
1643 $([IPython.events]).trigger("trust_changed.Notebook", trusted);
1642 $([IPython.events]).trigger("trust_changed.Notebook", trusted);
@@ -1814,21 +1813,6 b' var IPython = (function (IPython) {'
1814 * @method trust_notebook
1813 * @method trust_notebook
1815 */
1814 */
1816 Notebook.prototype.trust_notebook = function (extra_settings) {
1815 Notebook.prototype.trust_notebook = function (extra_settings) {
1817 // We do the call with settings so we can set cache to false.
1818
1819 var settings = {
1820 processData : false,
1821 cache : false,
1822 type : "POST",
1823 success : $.proxy(this._trust_notebook_success, this),
1824 error : $.proxy(this._trust_notebook_error, this)
1825 };
1826 if (extra_settings) {
1827 for (var key in extra_settings) {
1828 settings[key] = extra_settings[key];
1829 }
1830 }
1831
1832 var body = $("<div>").append($("<p>")
1816 var body = $("<div>").append($("<p>")
1833 .text("A trusted IPython notebook may execute hidden malicious code ")
1817 .text("A trusted IPython notebook may execute hidden malicious code ")
1834 .append($("<strong>")
1818 .append($("<strong>")
@@ -1853,30 +1837,23 b' var IPython = (function (IPython) {'
1853 Trust : {
1837 Trust : {
1854 class : "btn-danger",
1838 class : "btn-danger",
1855 click : function () {
1839 click : function () {
1856 $([IPython.events]).trigger('notebook_trusting.Notebook');
1840 var cells = nb.get_cells();
1857 var url = utils.url_join_encode(
1841 for (var i = 0; i < cells.length; i++) {
1858 nb.base_url,
1842 var cell = cells[i];
1859 'api/notebooks',
1843 if (cell.cell_type == 'code') {
1860 nb.notebook_path,
1844 cell.output_area.trusted = true;
1861 nb.notebook_name,
1845 }
1862 'trust'
1846 }
1863 );
1847 $([IPython.events]).on('notebook_saved.Notebook', function () {
1864 $.ajax(url, settings);
1848 window.location.reload();
1849 });
1850 nb.save_notebook();
1865 }
1851 }
1866 }
1852 }
1867 }
1853 }
1868 });
1854 });
1869 };
1855 };
1870
1856
1871 Notebook.prototype._trust_notebook_success = function (data, status, xhr) {
1872 $([IPython.events]).trigger('notebook_trusted.Notebook');
1873 window.location.reload();
1874 };
1875
1876 Notebook.prototype._trust_notebook_error = function (xhr, status, error) {
1877 $([IPython.events]).trigger('notebook_trust_failed.Notebook', [xhr, status, error]);
1878 };
1879
1880 Notebook.prototype.new_notebook = function(){
1857 Notebook.prototype.new_notebook = function(){
1881 var path = this.notebook_path;
1858 var path = this.notebook_path;
1882 var base_url = this.base_url;
1859 var base_url = this.base_url;
General Comments 0
You need to be logged in to leave comments. Login now