Commit d9bb3f18 authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

add more comments on the algorithm

parent 19e77add
......@@ -448,12 +448,6 @@ class AutoMergeSplitUpdateFormSet(forms.BaseModelFormSet):
self.has_her_identifier = False
def save(self, commit=True):
# objects = super().save(commit=False)
# self.save_m2m()
# for obj, reason in self.changed_objects:
# def saveXXX(self, commit=True):
assert (self.__data_source is not None)
assert commit, "It has to be actually saved in DB"
objects = super().save(commit=False)
......@@ -469,19 +463,25 @@ class AutoMergeSplitUpdateFormSet(forms.BaseModelFormSet):
if self.has_her_identifier:
alter_egos = alter_egos.filter(her_identifier=obj.her_identifier)
# alter_ego is the object to which we have to rename the obj
alter_ego = alter_egos.first()
# If there is no alter_ego we may have to build one new
if alter_ego is None:
# If we can get the is_ncbi_identifier_value elsewhere then we re-use it
if 'identifier' in reason:
identifier_alter_ego = obj.__class__.objects.filter(identifier=obj.identifier).first()
if identifier_alter_ego is None:
obj.is_ncbi_identifier_value = None
obj.is_ncbi_identifier_value = identifier_alter_ego.is_ncbi_identifier_value
# If the object is not used by someone else then we just change it
if obj.data_source.count() == 1:
# obj is used, we clone it = None
# And use this copy as its alter_ego
alter_ego = obj
# remove the old instance from the current data_source
......@@ -490,7 +490,7 @@ class AutoMergeSplitUpdateFormSet(forms.BaseModelFormSet):
# in any case, replace the instance that was about to be returned by the alter ego/newly created one
indexed_objects[] = alter_ego
# obj is now an other db instance, while old_o is still pointing to the original db instance
# obj is now a new db instance, while old_o is still pointing to the original db instance
# add the new instance to the data source
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment