Преглед на файлове

HUE-3410 [editor] Track the parent of an history query

Romain Rigaux преди 9 години
родител
ревизия
1fffdab
променени са 2 файла, в които са добавени 13 реда и са изтрити 4 реда
  1. 10 3
      desktop/libs/notebook/src/notebook/api.py
  2. 3 1
      desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

+ 10 - 3
desktop/libs/notebook/src/notebook/api.py

@@ -238,9 +238,9 @@ def save_notebook(request):
   notebook = json.loads(request.POST.get('notebook', '{}'))
   notebook_type = notebook.get('type', 'notebook')
   parent_uuid = notebook.get('parent_uuid', None)
-  parent = Document2.objects.get_home_directory(request.user)
+  parent_directory = Document2.objects.get_home_directory(request.user)
   if parent_uuid:
-    parent = Document2.objects.get_by_uuid(parent_uuid)
+    parent_directory = Document2.objects.get_by_uuid(parent_uuid)
 
   if notebook.get('id'):
     notebook_doc = Document2.objects.get(id=notebook['id'])
@@ -252,7 +252,7 @@ def save_notebook(request):
   notebook_doc.update_data(notebook)
   notebook_doc.name = notebook_doc1.name = notebook['name']
   notebook_doc.description = notebook_doc1.description = notebook['description']
-  notebook_doc.parent_directory = parent
+  notebook_doc.parent_directory = parent_directory
   notebook_doc.save()
   notebook_doc1.save()
 
@@ -274,6 +274,13 @@ def _historify(notebook, user):
     owner=user,
     is_history=True
   )
+
+  print notebook['parentUuid']
+  if notebook['parentUuid']:
+    parent_doc = Document2.objects.get(uuid=notebook['parentUuid'])
+    if parent_doc.can_write(user):
+      history_doc.dependencies.add(parent_doc)
+
   Document.objects.link(
     history_doc,
     name=history_doc.name,

+ 3 - 1
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -734,7 +734,7 @@
 
     self.isFetchingData = false;
     self.fetchResultData = function (rows, startOver) {
-      if (!self.isFetchingData) {
+      if (! self.isFetchingData) {
         self.isFetchingData = true;
         logGA('fetchResult/' + rows + '/' + startOver);
         $.post("/notebook/api/fetch_result_data", {
@@ -999,6 +999,7 @@
 
     self.id = ko.observable(typeof notebook.id != "undefined" && notebook.id != null ? notebook.id : null);
     self.uuid = ko.observable(typeof notebook.uuid != "undefined" && notebook.uuid != null ? notebook.uuid : UUID());
+    self.parentUuid = ko.observable(typeof notebook.parentUuid != "undefined" && notebook.parentUuid != null ? notebook.parentUuid : null);
     self.name = ko.observable(typeof notebook.name != "undefined" && notebook.name != null ? notebook.name : 'My Notebook');
     self.description = ko.observable(typeof notebook.description != "undefined" && notebook.description != null ? notebook.description: '');
     self.type = ko.observable(typeof notebook.type != "undefined" && notebook.type != null ? notebook.type : 'notebook');
@@ -1184,6 +1185,7 @@
      return {
          id: self.id,
          uuid: self.uuid,
+         parentUuid: self.parentUuid,
          sessions: self.sessions,
          type: self.type
       };