* 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,19 +1683,14 @@ 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."""
|
||||||
#
|
|
||||||
# Check any *valid* birthdates in the list to insure that they are in
|
|
||||||
# numerically increasing order.
|
|
||||||
#
|
|
||||||
#-------------------------------------------------------------------------
|
|
||||||
def birth_dates_in_order(list):
|
|
||||||
inorder = 1
|
inorder = 1
|
||||||
prev_date = "00000000"
|
prev_date = "00000000"
|
||||||
for i in range(len(list)):
|
for i in range(len(list)):
|
||||||
child = list[i]
|
child_id = list[i]
|
||||||
|
child = self.db.find_person_from_id(child_id)
|
||||||
bday = child.get_birth().get_date_object()
|
bday = child.get_birth().get_date_object()
|
||||||
child_date = sort.build_sort_date(bday)
|
child_date = sort.build_sort_date(bday)
|
||||||
if (child_date == "99999999"):
|
if (child_date == "99999999"):
|
||||||
@ -1706,18 +1701,12 @@ def birth_dates_in_order(list):
|
|||||||
inorder = 0
|
inorder = 0
|
||||||
return inorder
|
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)):
|
||||||
#
|
|
||||||
# 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)
|
return(list)
|
||||||
|
|
||||||
# Build the person's date string once
|
# Build the person's date string once
|
||||||
@ -1727,7 +1716,8 @@ def reorder_child_list(person, list):
|
|||||||
index = list.index(person)
|
index = list.index(person)
|
||||||
target = index
|
target = index
|
||||||
for i in range(index-1, -1, -1):
|
for i in range(index-1, -1, -1):
|
||||||
other_bday = sort.build_sort_date(list[i].get_birth().get_date_object())
|
other = self.db.find_person_from_id(list[i])
|
||||||
|
other_bday = sort.build_sort_date(other.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):
|
||||||
@ -1736,7 +1726,8 @@ def reorder_child_list(person, list):
|
|||||||
# Now try moving to a later position in the list
|
# Now try moving to a later position in the list
|
||||||
if (target == index):
|
if (target == index):
|
||||||
for i in range(index, len(list)):
|
for i in range(index, len(list)):
|
||||||
other_bday = sort.build_sort_date(list[i].get_birth().get_date_object())
|
other = self.db.find_person_from_id(list[i])
|
||||||
|
other_bday = sort.build_sort_date(other.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):
|
||||||
@ -1744,8 +1735,8 @@ def reorder_child_list(person, list):
|
|||||||
|
|
||||||
# Actually need to move? Do it now.
|
# Actually need to move? Do it now.
|
||||||
if (target != index):
|
if (target != index):
|
||||||
list.remove(person)
|
list.remove(person.get_id())
|
||||||
list.insert(target,person)
|
list.insert(target,person.get_id())
|
||||||
return list
|
return list
|
||||||
|
|
||||||
|
|
||||||
|
@ -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