Add 'additive fields' concept to merge diff preview
This commit is contained in:
parent
7dd19c6d87
commit
fe978a9bd2
|
@ -413,6 +413,11 @@ class MasterView(View):
|
||||||
return self.merge_coalesce_fields
|
return self.merge_coalesce_fields
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
def get_merge_additive_fields(self):
|
||||||
|
if hasattr(self, 'merge_additive_fields'):
|
||||||
|
return self.merge_additive_fields
|
||||||
|
return []
|
||||||
|
|
||||||
def merge(self):
|
def merge(self):
|
||||||
"""
|
"""
|
||||||
Preview and execute a merge of two records.
|
Preview and execute a merge of two records.
|
||||||
|
@ -463,6 +468,11 @@ class MasterView(View):
|
||||||
for field in self.get_merge_coalesce_fields():
|
for field in self.get_merge_coalesce_fields():
|
||||||
if remove[field] and not keep[field]:
|
if remove[field] and not keep[field]:
|
||||||
result[field] = remove[field]
|
result[field] = remove[field]
|
||||||
|
for field in self.get_merge_additive_fields():
|
||||||
|
if isinstance(keep[field], (list, tuple)):
|
||||||
|
result[field] = sorted(set(remove[field] + keep[field]))
|
||||||
|
else:
|
||||||
|
result[field] = remove[field] + keep[field]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def merge_objects(self, removing, keeping):
|
def merge_objects(self, removing, keeping):
|
||||||
|
|
Loading…
Reference in a new issue