* src/RelLib.py: fix syntax error
* src/EditPerson.py: fix reordering of children * svn: r2827
This commit is contained in:
parent
7ed2f0551e
commit
45c712e8cd
@ -1438,11 +1438,11 @@ class EditPerson:
|
|||||||
family = self.person.get_main_parents_family_id()
|
family = self.person.get_main_parents_family_id()
|
||||||
if (family):
|
if (family):
|
||||||
f = self.db.find_family_no_map(family)
|
f = self.db.find_family_no_map(family)
|
||||||
new_order = reorder_child_list(self.person,f.get_child_id_list())
|
new_order = self.reorder_child_list(self.person,f.get_child_id_list())
|
||||||
f.set_child_id_list(new_order)
|
f.set_child_id_list(new_order)
|
||||||
for (family, rel1, rel2) in self.person.get_parent_family_id_list():
|
for (family, rel1, rel2) in self.person.get_parent_family_id_list():
|
||||||
f = self.db.find_family_no_map(family)
|
f = self.db.find_family_no_map(family)
|
||||||
new_order = reorder_child_list(self.person,f.get_child_id_list())
|
new_order = self.reorder_child_list(self.person,f.get_child_id_list())
|
||||||
f.set_child_id_list(new_order)
|
f.set_child_id_list(new_order)
|
||||||
|
|
||||||
self.death.set_date(unicode(self.ddate.get_text()))
|
self.death.set_date(unicode(self.ddate.get_text()))
|
||||||
@ -1683,70 +1683,61 @@ class EditPerson:
|
|||||||
self.ntype_field.entry.set_text(_(self.pname.get_type()))
|
self.ntype_field.entry.set_text(_(self.pname.get_type()))
|
||||||
self.title.set_text(self.pname.get_title())
|
self.title.set_text(self.pname.get_title())
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
def birth_dates_in_order(self,list):
|
||||||
#
|
"""Check any *valid* birthdates in the list to insure that they are in
|
||||||
# birth_dates_in_order
|
numerically increasing order."""
|
||||||
#
|
inorder = 1
|
||||||
# Check any *valid* birthdates in the list to insure that they are in
|
prev_date = "00000000"
|
||||||
# numerically increasing order.
|
for i in range(len(list)):
|
||||||
#
|
child_id = list[i]
|
||||||
#-------------------------------------------------------------------------
|
child = self.db.find_person_from_id(child_id)
|
||||||
def birth_dates_in_order(list):
|
bday = child.get_birth().get_date_object()
|
||||||
inorder = 1
|
child_date = sort.build_sort_date(bday)
|
||||||
prev_date = "00000000"
|
if (child_date == "99999999"):
|
||||||
for i in range(len(list)):
|
continue
|
||||||
child = list[i]
|
if (prev_date <= child_date): # <= allows for twins
|
||||||
bday = child.get_birth().get_date_object()
|
prev_date = child_date
|
||||||
child_date = sort.build_sort_date(bday)
|
else:
|
||||||
if (child_date == "99999999"):
|
inorder = 0
|
||||||
continue
|
return inorder
|
||||||
if (prev_date <= child_date): # <= allows for twins
|
|
||||||
prev_date = child_date
|
|
||||||
else:
|
|
||||||
inorder = 0
|
|
||||||
return inorder
|
|
||||||
|
|
||||||
|
def reorder_child_list(self, person, list):
|
||||||
|
"""Reorder the child list to put the specified person in his/her
|
||||||
|
correct birth order. Only check *valid* birthdates. Move the person
|
||||||
|
as short a distance as possible."""
|
||||||
|
|
||||||
|
if (self.birth_dates_in_order(list)):
|
||||||
|
return(list)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
# Build the person's date string once
|
||||||
#
|
person_bday = sort.build_sort_date(person.get_birth().get_date_object())
|
||||||
# reorder_child_list
|
|
||||||
#
|
|
||||||
# Reorder the child list to put the specified person in his/her
|
|
||||||
# correct birth order. Only check *valid* birthdates. Move the person
|
|
||||||
# as short a distance as possible.
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def reorder_child_list(person, list):
|
|
||||||
if (birth_dates_in_order(list)):
|
|
||||||
return(list)
|
|
||||||
|
|
||||||
# Build the person's date string once
|
# First, see if the person needs to be moved forward in the list
|
||||||
person_bday = sort.build_sort_date(person.get_birth().get_date_object())
|
index = list.index(person)
|
||||||
|
target = index
|
||||||
# First, see if the person needs to be moved forward in the list
|
for i in range(index-1, -1, -1):
|
||||||
index = list.index(person)
|
other = self.db.find_person_from_id(list[i])
|
||||||
target = index
|
other_bday = sort.build_sort_date(other.get_birth().get_date_object())
|
||||||
for i in range(index-1, -1, -1):
|
|
||||||
other_bday = sort.build_sort_date(list[i].get_birth().get_date_object())
|
|
||||||
if (other_bday == "99999999"):
|
|
||||||
continue;
|
|
||||||
if (person_bday < other_bday):
|
|
||||||
target = i
|
|
||||||
|
|
||||||
# Now try moving to a later position in the list
|
|
||||||
if (target == index):
|
|
||||||
for i in range(index, len(list)):
|
|
||||||
other_bday = sort.build_sort_date(list[i].get_birth().get_date_object())
|
|
||||||
if (other_bday == "99999999"):
|
if (other_bday == "99999999"):
|
||||||
continue;
|
continue;
|
||||||
if (person_bday > other_bday):
|
if (person_bday < other_bday):
|
||||||
target = i
|
target = i
|
||||||
|
|
||||||
# Actually need to move? Do it now.
|
# Now try moving to a later position in the list
|
||||||
if (target != index):
|
if (target == index):
|
||||||
list.remove(person)
|
for i in range(index, len(list)):
|
||||||
list.insert(target,person)
|
other = self.db.find_person_from_id(list[i])
|
||||||
return list
|
other_bday = sort.build_sort_date(other.get_birth().get_date_object())
|
||||||
|
if (other_bday == "99999999"):
|
||||||
|
continue;
|
||||||
|
if (person_bday > other_bday):
|
||||||
|
target = i
|
||||||
|
|
||||||
|
# Actually need to move? Do it now.
|
||||||
|
if (target != index):
|
||||||
|
list.remove(person.get_id())
|
||||||
|
list.insert(target,person.get_id())
|
||||||
|
return list
|
||||||
|
|
||||||
|
|
||||||
def short(val,size=60):
|
def short(val,size=60):
|
||||||
|
@ -1797,7 +1797,7 @@ class Family(SourceNote):
|
|||||||
|
|
||||||
def get_father_id(self):
|
def get_father_id(self):
|
||||||
"""returns the father of the Family"""
|
"""returns the father of the Family"""
|
||||||
return father_id
|
return self.father_id
|
||||||
|
|
||||||
def set_mother_id(self,person):
|
def set_mother_id(self,person):
|
||||||
"""sets the mother of the Family to the specfied Person"""
|
"""sets the mother of the Family to the specfied Person"""
|
||||||
@ -2190,7 +2190,7 @@ class GrampsDB:
|
|||||||
def get_number_of_people(self):
|
def get_number_of_people(self):
|
||||||
return len(self.person_map)
|
return len(self.person_map)
|
||||||
|
|
||||||
v def get_person_keys(self):
|
def get_person_keys(self):
|
||||||
return self.person_map.keys()
|
return self.person_map.keys()
|
||||||
|
|
||||||
def sort_by_name(self,f,s):
|
def sort_by_name(self,f,s):
|
||||||
|
Loading…
Reference in New Issue
Block a user