Fixed problem with parents

svn: r279
This commit is contained in:
Don Allingham 2001-08-02 20:58:19 +00:00
parent 839c050deb
commit f7998899a5
3 changed files with 60 additions and 9 deletions

View File

@ -292,6 +292,10 @@ def on_close_marriage_editor(obj):
val = const.save_frel(relation)
if val == "Partners":
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)
utils.modified()

View File

@ -969,6 +969,8 @@ def find_family(father,mother):
for family in families:
if family.getFather() == father and family.getMother() == mother:
return family
elif family.getFather() == mother and family.getMother() == father:
return family
family = database.newFamily()
family.setFather(father)
@ -1024,13 +1026,16 @@ def change_family_type(family,mrel,frel):
active_person.setMainFamily(family)
active_person.removeAltFamily(family)
utils.modified()
return
break
if mrel == fam[1] and frel == fam[2]:
break
if mrel != fam[1] or frel != fam[2]:
active_person.removeAltFamily(family)
active_person.addAltFamily(family,mrel,frel)
utils.modified()
return
active_person.addAltFamily(family,mrel,frel)
break
else:
active_person.addAltFamily(family,mrel,frel)
utils.modified()
#-------------------------------------------------------------------------
@ -1052,19 +1057,23 @@ def on_save_parents_clicked(obj):
if select_father or select_mother:
if select_mother.getGender() == Person.male and \
select_father.getGender() == Person.female:
x = select_mother
select_mother = select_father
select_father = x
type = "Unknown"
family = find_family(select_father,select_mother)
family.setFather(select_mother)
family.setMother(select_father)
x = select_father
select_father = select_mother
select_mother = x
elif select_mother.getGender() != select_father.getGender():
if type == "Partners":
type = "Unknown"
family = find_family(select_father,select_mother)
else:
type = "Partners"
family = find_family(select_father,select_mother)
family = find_family(select_father,select_mother)
else:
family = None
print type,family
family.setRelationship(type)
change_family_type(family,mrel,frel)

View File

@ -44,6 +44,7 @@ def runTool(database,active_person,callback):
checker = CheckIntegrity(database)
checker.check_for_broken_family_links()
checker.cleanup_missing_photos()
checker.check_parent_relationships()
checker.cleanup_empty_families(0)
checker.report()
@ -66,6 +67,7 @@ class CheckIntegrity:
self.bad_person_photo = []
self.empty_family = []
self.broken_links = []
self.fam_rel = []
#-------------------------------------------------------------------------
#
@ -125,6 +127,36 @@ class CheckIntegrity:
else:
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)
efam = len(self.empty_family)
blink = len(self.broken_links)
errors = blink + efam + pphotos + fphotos
rel = len(self.fam_rel)
errors = blink + efam + pphotos + fphotos + rel
if errors == 0:
GnomeOkDialog(_("No errors were found"))
@ -150,6 +184,10 @@ class CheckIntegrity:
text = text + _("1 empty family was found\n")
elif efam > 1:
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:
text = text + _("1 broken family image was found\n")
elif fphotos > 1: