Fixed problem with parents
svn: r279
This commit is contained in:
parent
839c050deb
commit
f7998899a5
@ -292,6 +292,10 @@ def on_close_marriage_editor(obj):
|
|||||||
val = const.save_frel(relation)
|
val = const.save_frel(relation)
|
||||||
if val == "Partners":
|
if val == "Partners":
|
||||||
val = "Unknown"
|
val = "Unknown"
|
||||||
|
if father.getGender() == Person.female or \
|
||||||
|
mother.getGender() == Person.male:
|
||||||
|
family_obj.family.setFather(mother)
|
||||||
|
family_obj.family.setMother(father)
|
||||||
family_obj.family.setRelationship(val)
|
family_obj.family.setRelationship(val)
|
||||||
utils.modified()
|
utils.modified()
|
||||||
|
|
||||||
|
@ -969,6 +969,8 @@ def find_family(father,mother):
|
|||||||
for family in families:
|
for family in families:
|
||||||
if family.getFather() == father and family.getMother() == mother:
|
if family.getFather() == father and family.getMother() == mother:
|
||||||
return family
|
return family
|
||||||
|
elif family.getFather() == mother and family.getMother() == father:
|
||||||
|
return family
|
||||||
|
|
||||||
family = database.newFamily()
|
family = database.newFamily()
|
||||||
family.setFather(father)
|
family.setFather(father)
|
||||||
@ -1024,13 +1026,16 @@ def change_family_type(family,mrel,frel):
|
|||||||
active_person.setMainFamily(family)
|
active_person.setMainFamily(family)
|
||||||
active_person.removeAltFamily(family)
|
active_person.removeAltFamily(family)
|
||||||
utils.modified()
|
utils.modified()
|
||||||
return
|
break
|
||||||
|
if mrel == fam[1] and frel == fam[2]:
|
||||||
|
break
|
||||||
if mrel != fam[1] or frel != fam[2]:
|
if mrel != fam[1] or frel != fam[2]:
|
||||||
active_person.removeAltFamily(family)
|
active_person.removeAltFamily(family)
|
||||||
active_person.addAltFamily(family,mrel,frel)
|
active_person.addAltFamily(family,mrel,frel)
|
||||||
utils.modified()
|
utils.modified()
|
||||||
return
|
break
|
||||||
active_person.addAltFamily(family,mrel,frel)
|
else:
|
||||||
|
active_person.addAltFamily(family,mrel,frel)
|
||||||
utils.modified()
|
utils.modified()
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
@ -1052,19 +1057,23 @@ def on_save_parents_clicked(obj):
|
|||||||
if select_father or select_mother:
|
if select_father or select_mother:
|
||||||
if select_mother.getGender() == Person.male and \
|
if select_mother.getGender() == Person.male and \
|
||||||
select_father.getGender() == Person.female:
|
select_father.getGender() == Person.female:
|
||||||
x = select_mother
|
family = find_family(select_father,select_mother)
|
||||||
select_mother = select_father
|
family.setFather(select_mother)
|
||||||
select_father = x
|
family.setMother(select_father)
|
||||||
type = "Unknown"
|
x = select_father
|
||||||
|
select_father = select_mother
|
||||||
|
select_mother = x
|
||||||
elif select_mother.getGender() != select_father.getGender():
|
elif select_mother.getGender() != select_father.getGender():
|
||||||
if type == "Partners":
|
if type == "Partners":
|
||||||
type = "Unknown"
|
type = "Unknown"
|
||||||
|
family = find_family(select_father,select_mother)
|
||||||
else:
|
else:
|
||||||
type = "Partners"
|
type = "Partners"
|
||||||
family = find_family(select_father,select_mother)
|
family = find_family(select_father,select_mother)
|
||||||
else:
|
else:
|
||||||
family = None
|
family = None
|
||||||
|
|
||||||
|
print type,family
|
||||||
family.setRelationship(type)
|
family.setRelationship(type)
|
||||||
|
|
||||||
change_family_type(family,mrel,frel)
|
change_family_type(family,mrel,frel)
|
||||||
|
@ -44,6 +44,7 @@ def runTool(database,active_person,callback):
|
|||||||
checker = CheckIntegrity(database)
|
checker = CheckIntegrity(database)
|
||||||
checker.check_for_broken_family_links()
|
checker.check_for_broken_family_links()
|
||||||
checker.cleanup_missing_photos()
|
checker.cleanup_missing_photos()
|
||||||
|
checker.check_parent_relationships()
|
||||||
checker.cleanup_empty_families(0)
|
checker.cleanup_empty_families(0)
|
||||||
checker.report()
|
checker.report()
|
||||||
|
|
||||||
@ -66,6 +67,7 @@ class CheckIntegrity:
|
|||||||
self.bad_person_photo = []
|
self.bad_person_photo = []
|
||||||
self.empty_family = []
|
self.empty_family = []
|
||||||
self.broken_links = []
|
self.broken_links = []
|
||||||
|
self.fam_rel = []
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -125,6 +127,36 @@ class CheckIntegrity:
|
|||||||
else:
|
else:
|
||||||
self.empty_family.append(family)
|
self.empty_family.append(family)
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#
|
||||||
|
#-------------------------------------------------------------------------
|
||||||
|
def check_parent_relationships(self):
|
||||||
|
|
||||||
|
family_list = self.db.getFamilyMap().values()[:]
|
||||||
|
for family in family_list:
|
||||||
|
father = family.getFather()
|
||||||
|
mother = family.getMother()
|
||||||
|
type = family.getRelationship()
|
||||||
|
|
||||||
|
if type != "Partners":
|
||||||
|
if father.getGender() == mother.getGender():
|
||||||
|
family.setRelationship("Partners")
|
||||||
|
self.fam_rel.append(family)
|
||||||
|
elif father.getGender() != RelLib.Person.male or \
|
||||||
|
mother.getGender() != RelLib.Person.female:
|
||||||
|
family.setFather(mother)
|
||||||
|
family.setMother(father)
|
||||||
|
self.fam_rel.append(family)
|
||||||
|
else:
|
||||||
|
if father.getGender() != mother.getGender():
|
||||||
|
family.setRelationship("Unknown")
|
||||||
|
self.fam_rel.append(family)
|
||||||
|
if father.getGender() == RelLib.Person.female:
|
||||||
|
family.setFather(mother)
|
||||||
|
family.setMother(father)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
@ -135,7 +167,9 @@ class CheckIntegrity:
|
|||||||
pphotos = len(self.bad_person_photo)
|
pphotos = len(self.bad_person_photo)
|
||||||
efam = len(self.empty_family)
|
efam = len(self.empty_family)
|
||||||
blink = len(self.broken_links)
|
blink = len(self.broken_links)
|
||||||
errors = blink + efam + pphotos + fphotos
|
rel = len(self.fam_rel)
|
||||||
|
|
||||||
|
errors = blink + efam + pphotos + fphotos + rel
|
||||||
|
|
||||||
if errors == 0:
|
if errors == 0:
|
||||||
GnomeOkDialog(_("No errors were found"))
|
GnomeOkDialog(_("No errors were found"))
|
||||||
@ -150,6 +184,10 @@ class CheckIntegrity:
|
|||||||
text = text + _("1 empty family was found\n")
|
text = text + _("1 empty family was found\n")
|
||||||
elif efam > 1:
|
elif efam > 1:
|
||||||
text = text + _("%d empty families were found\n") % efam
|
text = text + _("%d empty families were found\n") % efam
|
||||||
|
if rel == 1:
|
||||||
|
text = text + _("1 corrupted family relationship fixed\n")
|
||||||
|
elif rel > 1:
|
||||||
|
text = text + _("%d corrupted family relationship fixed\n") % rel
|
||||||
if fphotos == 1:
|
if fphotos == 1:
|
||||||
text = text + _("1 broken family image was found\n")
|
text = text + _("1 broken family image was found\n")
|
||||||
elif fphotos > 1:
|
elif fphotos > 1:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user