Selaa lähdekoodia

[editor] Fixed saving messages for the query editor

Enrico Berti 10 vuotta sitten
vanhempi
commit
1159515a24

+ 2 - 17
desktop/libs/notebook/src/notebook/api.py

@@ -218,22 +218,7 @@ def save_notebook(request):
 
   response['status'] = 0
   response['id'] = notebook_doc.id
-  response['message'] = _('Notebook saved !')
-
-  return JsonResponse(response)
-
-
-@require_GET
-@check_document_access_permission()
-def open_notebook(request):
-  response = {'status': -1}
-
-  notebook_id = request.GET.get('notebook')
-  notebook = Notebook(document=Document2.objects.get(id=notebook_id))
-
-  response['status'] = 0
-  response['notebook'] = notebook.get_json()
-  response['message'] = _('Notebook saved !')
+  response['message'] = request.POST.get('editorMode') == 'true' and _('Query saved successfully') or _('Notebook saved successfully')
 
   return JsonResponse(response)
 
@@ -254,7 +239,7 @@ def close_notebook(request):
       LOG.exception('Error closing session %s' % str(e))
 
   response['status'] = 0
-  response['message'] = _('Notebook closed !')
+  response['message'] = _('Notebook closed successfully')
 
   return JsonResponse(response)
 

+ 4 - 2
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -881,7 +881,8 @@
 
     self.save = function () {
       $.post("/notebook/api/notebook/save", {
-        "notebook": ko.mapping.toJSON(self, SPARK_MAPPING)
+        "notebook": ko.mapping.toJSON(self, SPARK_MAPPING),
+        "editorMode": vm.editorMode
       }, function (data) {
         if (data.status == 0) {
           self.id(data.id);
@@ -902,7 +903,8 @@
 
     self.close = function () {
       $.post("/notebook/api/notebook/close", {
-        "notebook": ko.mapping.toJSON(self, SPARK_MAPPING)
+        "notebook": ko.mapping.toJSON(self, SPARK_MAPPING),
+        "editorMode": vm.editorMode
       });
     };
 

+ 0 - 1
desktop/libs/notebook/src/notebook/urls.py

@@ -56,7 +56,6 @@ urlpatterns += patterns('notebook.api',
   url(r'^api/get_logs', 'get_logs', name='get_logs'),
 
   url(r'^api/notebook/save$', 'save_notebook', name='save_notebook'),
-  url(r'^api/notebook/open$', 'open_notebook', name='open_notebook'),
   url(r'^api/notebook/close$', 'close_notebook', name='close_notebook'),
 )