Bläddra i källkod

HUE-4205 [doc2] Ignore history dependencies on import

Jenny Kim 9 år sedan
förälder
incheckning
e226625
1 ändrade filer med 5 tillägg och 0 borttagningar
  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
     else:  # Update existing doc or create new
       doc = _create_or_update_document_with_owner(doc, request.user, uuids_map)
       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
     # Set last modified date to now
     doc['fields']['last_modified'] = datetime.now().replace(microsecond=0).isoformat()
     doc['fields']['last_modified'] = datetime.now().replace(microsecond=0).isoformat()
     docs.append(doc)
     docs.append(doc)