3657: Calculation od step siblings is incorrect in narrated Web report

svn: r14667
This commit is contained in:
Benny Malengier 2010-03-07 16:09:06 +00:00
parent 8efe5a27d6
commit a3b52f5878

View File

@ -4162,7 +4162,8 @@ class IndividualPage(BasePage):
childlist = [child_ref.ref for child_ref in child_ref_list] childlist = [child_ref.ref for child_ref in child_ref_list]
sibling.update(childlist) sibling.update(childlist)
# now that we have all natural siblings, display them... # now that we have all siblings in families of the person,
# display them...
if sibling: if sibling:
trow = Html("tr") + ( trow = Html("tr") + (
Html("td", _("Siblings"), class_ = "ColumnAttribute", inline = True) Html("td", _("Siblings"), class_ = "ColumnAttribute", inline = True)
@ -4191,148 +4192,159 @@ class IndividualPage(BasePage):
# Also try to identify half-siblings # Also try to identify half-siblings
half_siblings = set() half_siblings = set()
# if we have a known father... ## FOLLOWING CODE IS WRONG, AS showallsiblings = False
showallsiblings = self.report.options['showhalfsiblings'] ## THIS CODE WILL NOT RUN
if father_handle and showallsiblings: ## TO FIX: the code only works if the user has his
# 1) get all of the families in which this father is involved ## half/step siblings in a specific way in the database,
# 2) get all of the children from those families ## however this way is not the official way
# 3) if the children are not already listed as siblings... ## The official way is:
# 4) then remember those children since we're going to list them ## 1. step or half siblings _must_ be present
father = db.get_person_from_handle(father_handle) ## somewhere in the same family. So the search
for family_handle in father.get_family_handle_list(): ## here over other families is wrong
family = db.get_family_from_handle(family_handle) ## 2. to determine the relationship, only the child
for half_child_ref in family.get_child_ref_list(): ## relationship must be looked at, nothing else!
half_child_handle = half_child_ref.ref showallsiblings = False #self.report.options['showhalfsiblings']
if half_child_handle not in sibling: ## # if we have a known father...
if half_child_handle != self.person.handle: ## if father_handle and showallsiblings:
# we have a new step/half sibling ## # 1) get all of the families in which this father is involved
half_siblings.add(half_child_handle) ## # 2) get all of the children from those families
## # 3) if the children are not already listed as siblings...
# do the same thing with the mother (see "father" just above): ## # 4) then remember those children since we're going to list them
if mother_handle and showallsiblings: ## father = db.get_person_from_handle(father_handle)
mother = db.get_person_from_handle(mother_handle) ## for family_handle in father.get_family_handle_list():
for family_handle in mother.get_family_handle_list(): ## family = db.get_family_from_handle(family_handle)
family = db.get_family_from_handle(family_handle) ## for half_child_ref in family.get_child_ref_list():
for half_child_ref in family.get_child_ref_list(): ## half_child_handle = half_child_ref.ref
half_child_handle = half_child_ref.ref ## if half_child_handle not in sibling:
if half_child_handle not in sibling: ## if half_child_handle != self.person.handle:
if half_child_handle != self.person.handle: ## # we have a new step/half sibling
# we have a new half sibling ## half_siblings.add(half_child_handle)
half_siblings.add(half_child_handle) ##
## # do the same thing with the mother (see "father" just above):
# now that we have all half- siblings, display them... ## if mother_handle and showallsiblings:
if half_siblings: ## mother = db.get_person_from_handle(mother_handle)
trow = Html("tr") + ( ## for family_handle in mother.get_family_handle_list():
Html("td", _("Half Siblings"), class_ = "ColumnAttribute", inline = True) ## family = db.get_family_from_handle(family_handle)
) ## for half_child_ref in family.get_child_ref_list():
table += trow ## half_child_handle = half_child_ref.ref
## if half_child_handle not in sibling:
tcell = Html("td", class_ = "ColumnValue") ## if half_child_handle != self.person.handle:
trow += tcell ## # we have a new half sibling
## half_siblings.add(half_child_handle)
ordered = Html("ol") ##
tcell += ordered ## # now that we have all half- siblings, display them...
## if half_siblings:
if birthorder: ## trow = Html("tr") + (
kids = sorted(add_birthdate(db, half_siblings)) ## Html("td", _("Half Siblings"), class_ = "ColumnAttribute", inline = True)
## )
ordered.extend( ## table += trow
self.display_child_link(child_handle) ##
for birth_date, child_handle in kids) ## tcell = Html("td", class_ = "ColumnValue")
else: ## trow += tcell
ordered += map(self.display_child_link, half_siblings) ##
## ordered = Html("ol")
# get step-siblings ## tcell += ordered
if showallsiblings: ##
step_siblings = set() ## if birthorder:
## kids = sorted(add_birthdate(db, half_siblings))
# to find the step-siblings, we need to identify ##
# all of the families that can be linked back to ## ordered.extend(
# the current person, and then extract the children ## self.display_child_link(child_handle)
# from those families ## for birth_date, child_handle in kids)
all_family_handles = set() ## else:
all_parent_handles = set() ## ordered += map(self.display_child_link, half_siblings)
tmp_parent_handles = set() ##
## # get step-siblings
# first we queue up the parents we know about ## if showallsiblings:
if mother_handle: ## step_siblings = set()
tmp_parent_handles.add(mother_handle) ##
if father_handle: ## # to find the step-siblings, we need to identify
tmp_parent_handles.add(father_handle) ## # all of the families that can be linked back to
## # the current person, and then extract the children
while len(tmp_parent_handles): ## # from those families
# pop the next parent from the set ## all_family_handles = set()
parent_handle = tmp_parent_handles.pop() ## all_parent_handles = set()
## tmp_parent_handles = set()
# add this parent to our official list ##
all_parent_handles.add(parent_handle) ## # first we queue up the parents we know about
## if mother_handle:
# get all families with this parent ## tmp_parent_handles.add(mother_handle)
parent = db.get_person_from_handle(parent_handle) ## if father_handle:
for family_handle in parent.get_family_handle_list(): ## tmp_parent_handles.add(father_handle)
##
all_family_handles.add(family_handle) ## while len(tmp_parent_handles):
## # pop the next parent from the set
# we already have 1 parent from this family ## parent_handle = tmp_parent_handles.pop()
# (see "parent" above) so now see if we need ##
# to queue up the other parent ## # add this parent to our official list
family = db.get_family_from_handle(family_handle) ## all_parent_handles.add(parent_handle)
tmp_mother_handle = family.get_mother_handle() ##
if tmp_mother_handle and \ ## # get all families with this parent
tmp_mother_handle != parent and \ ## parent = db.get_person_from_handle(parent_handle)
tmp_mother_handle not in tmp_parent_handles and \ ## for family_handle in parent.get_family_handle_list():
tmp_mother_handle not in all_parent_handles: ##
tmp_parent_handles.add(tmp_mother_handle) ## all_family_handles.add(family_handle)
tmp_father_handle = family.get_father_handle() ##
if tmp_father_handle and \ ## # we already have 1 parent from this family
tmp_father_handle != parent and \ ## # (see "parent" above) so now see if we need
tmp_father_handle not in tmp_parent_handles and \ ## # to queue up the other parent
tmp_father_handle not in all_parent_handles: ## family = db.get_family_from_handle(family_handle)
tmp_parent_handles.add(tmp_father_handle) ## tmp_mother_handle = family.get_mother_handle()
## if tmp_mother_handle and \
# once we get here, we have all of the families ## tmp_mother_handle != parent and \
# that could result in step-siblings; note that ## tmp_mother_handle not in tmp_parent_handles and \
# we can only have step-siblings if the number ## tmp_mother_handle not in all_parent_handles:
# of families involved is > 1 ## tmp_parent_handles.add(tmp_mother_handle)
## tmp_father_handle = family.get_father_handle()
if len(all_family_handles) > 1: ## if tmp_father_handle and \
while len(all_family_handles): ## tmp_father_handle != parent and \
# pop the next family from the set ## tmp_father_handle not in tmp_parent_handles and \
family_handle = all_family_handles.pop() ## tmp_father_handle not in all_parent_handles:
# look in this family for children we haven't yet seen ## tmp_parent_handles.add(tmp_father_handle)
family = db.get_family_from_handle(family_handle) ##
for step_child_ref in family.get_child_ref_list(): ## # once we get here, we have all of the families
step_child_handle = step_child_ref.ref ## # that could result in step-siblings; note that
if step_child_handle not in sibling and \ ## # we can only have step-siblings if the number
step_child_handle not in half_siblings and \ ## # of families involved is > 1
step_child_handle != self.person.handle: ##
# we have a new step sibling ## if len(all_family_handles) > 1:
step_siblings.add(step_child_handle) ## while len(all_family_handles):
## # pop the next family from the set
# now that we have all step- siblings, display them... ## family_handle = all_family_handles.pop()
if len(step_siblings): ## # look in this family for children we haven't yet seen
trow = Html("tr") + ( ## family = db.get_family_from_handle(family_handle)
Html("td", _("Step Siblings"), class_ = "ColumnAttribute", inline = True) ## for step_child_ref in family.get_child_ref_list():
) ## step_child_handle = step_child_ref.ref
table += trow ## if step_child_handle not in sibling and \
## step_child_handle not in half_siblings and \
tcell = Html("td", class_ = "ColumnValue") ## step_child_handle != self.person.handle:
trow += tcell ## # we have a new step sibling
## step_siblings.add(step_child_handle)
ordered = Html("ol") ##
tcell += ordered ## # now that we have all step- siblings, display them...
## if len(step_siblings):
if birthorder: ## trow = Html("tr") + (
kids = [] ## Html("td", _("Step Siblings"), class_ = "ColumnAttribute", inline = True)
kids = sorted(add_birthdate(db, step_siblings)) ## )
## table += trow
ordered.extend( ##
self.display_child_link(child_handle) ## tcell = Html("td", class_ = "ColumnValue")
for birth_date, child_handle in kids) ## trow += tcell
##
else: ## ordered = Html("ol")
ordered += map(self.display_child_link, ## tcell += ordered
step_siblings) ##
## if birthorder:
## kids = []
## kids = sorted(add_birthdate(db, step_siblings))
##
## ordered.extend(
## self.display_child_link(child_handle)
## for birth_date, child_handle in kids)
##
## else:
## ordered += map(self.display_child_link,
## step_siblings)
# return parents division to its caller # return parents division to its caller
return section return section
@ -5875,11 +5887,12 @@ class NavWebOptions(MenuReportOptions):
showparents.set_help(_('Whether to include a parents column')) showparents.set_help(_('Whether to include a parents column'))
menu.add_option(category_name, 'showparents', showparents) menu.add_option(category_name, 'showparents', showparents)
showallsiblings = BooleanOption(_("Include half and/ or " # This is programmed wrong, remove
"step-siblings on the individual pages"), False) #showallsiblings = BooleanOption(_("Include half and/ or "
showallsiblings.set_help(_( "Whether to include half and/ or " # "step-siblings on the individual pages"), False)
"step-siblings with the parents and siblings")) #showallsiblings.set_help(_( "Whether to include half and/ or "
menu.add_option(category_name, 'showhalfsiblings', showallsiblings) # "step-siblings with the parents and siblings"))
#menu.add_option(category_name, 'showhalfsiblings', showallsiblings)
birthorder = BooleanOption(_('Sort all children in birth order'), False) birthorder = BooleanOption(_('Sort all children in birth order'), False)
birthorder.set_help(_('Whether to display children in birth order' birthorder.set_help(_('Whether to display children in birth order'