diff options
Diffstat (limited to 'ishtar_common')
| -rw-r--r-- | ishtar_common/data_importer.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/ishtar_common/data_importer.py b/ishtar_common/data_importer.py index 584917c8e..3ac7bba35 100644 --- a/ishtar_common/data_importer.py +++ b/ishtar_common/data_importer.py @@ -1264,7 +1264,6 @@ class Importer(object): # nosec: no catch to force continue processing of lines except: # nosec pass - data = update_data(self._pre_import_values, data) # put default values only if relevant for mandatory_keys, defaults in self._defaults: @@ -2069,18 +2068,20 @@ class Importer(object): self.new_objects.append((path, cls, new_dct)) else: # manage UNICITY_KEYS - only level 1 + new_values = {} if not path and self.UNICITY_KEYS: get_by_unicity_key = True for k in list(dct.keys()): if k not in self.UNICITY_KEYS and k != "defaults": if dct[k]: - defaults[k] = dct.pop(k) + new_values[k] = dct.pop(k) else: dct.pop(k) if "get_default" in dct and dct["get_default"]: dct.pop("get_default") new_dct = defaults.copy() new_dct.update(dct) + new_dct.update(new_values) dct = new_dct if self.simulate: @@ -2113,7 +2114,7 @@ class Importer(object): self.updated_objects.append([path, q.all()[0], dct, {}]) dct["defaults"] = defaults.copy() else: - if not dct and not defaults: + if not dct and not defaults and not new_values: obj = None else: if ( @@ -2126,6 +2127,7 @@ class Importer(object): else: created = True new_dct = dct.copy() + new_dct.update(new_values) for k in defaults: if k not in dct: new_dct[k] = defaults[k] @@ -2162,6 +2164,24 @@ class Importer(object): if k in self.concat_str: sep = self.concat_str[k] updated_dct[k] = val + sep + new_val + for k in new_values: + new_val = new_values[k] + if new_val is None or new_val == "": + continue + val = getattr(obj, k) + if obj and k == "data": + updated_dct[k] = update_data(obj.data, new_val) + elif ( + k in self.concats + and type(val) == str + and type(new_val) == str + ): + sep = "" + if k in self.concat_str: + sep = self.concat_str[k] + updated_dct[k] = val + sep + new_val + else: + updated_dct[k] = new_val if updated_dct: if self.simulate: self.updated_objects[-1][-1] = updated_dct |
