浏览代码

HUE-4205 [doc2] Ignore history dependencies on import

Jenny Kim 9 年之前
父节点
当前提交
e226625
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      desktop/core/src/desktop/api2.py

+ 5 - 0
desktop/core/src/desktop/api2.py

@@ -409,6 +409,11 @@ def import_documents(request):
     else:  # Update existing doc or create new
       doc = _create_or_update_document_with_owner(doc, request.user, uuids_map)
 
+    # If the doc contains any history dependencies, ignore them
+    # NOTE: this assumes that each dependency is exported as an array using the natural PK [uuid, version, is_history]
+    deps_minus_history = [dep for dep in doc.get('dependencies', []) if len(dep) >= 3 and not dep[2]]
+    doc['dependencies'] = deps_minus_history
+
     # Set last modified date to now
     doc['fields']['last_modified'] = datetime.now().replace(microsecond=0).isoformat()
     docs.append(doc)