Possible biological, half, and step siblings into NarrativeWeb.

svn: r18877
This commit is contained in:
Rob G. Healey 2012-02-14 02:33:08 +00:00
parent c8048fed81
commit e8567ae608

View File

@ -5302,11 +5302,11 @@ class ContactPage(BasePage):
# and close the file # and close the file
self.XHTMLWriter(contactpage, of) self.XHTMLWriter(contactpage, of)
################################################# """
# #
# creates the Individual Pages from the IndividualListPage # creates the Individual Pages from the IndividualListPage
# #
################################################# """
class IndividualPage(BasePage): class IndividualPage(BasePage):
gender_map = { gender_map = {
gen.lib.Person.MALE : _('male'), gen.lib.Person.MALE : _('male'),
@ -5334,6 +5334,9 @@ class IndividualPage(BasePage):
# decide if we will sort the birth order of siblings... # decide if we will sort the birth order of siblings...
self.birthorder = self.report.options['birthorder'] self.birthorder = self.report.options['birthorder']
# get the Relationship Calculator so that we can determine
# bio, half, step- siblings for use in display_ind_parents() ...
self.rel_class = rel_class self.rel_class = rel_class
of = self.report.create_file(person.get_handle(), "ppl") of = self.report.create_file(person.get_handle(), "ppl")
@ -5362,7 +5365,7 @@ class IndividualPage(BasePage):
individualdetail += sect2 individualdetail += sect2
# display parents # display parents
sect3 = self.display_ind_parents(self.ind_list) sect3 = self.display_ind_parents()
if sect3 is not None: if sect3 is not None:
individualdetail += sect3 individualdetail += sect3
@ -6183,7 +6186,7 @@ class IndividualPage(BasePage):
# return table columns to its caller # return table columns to its caller
return tcell1, tcell2 return tcell1, tcell2
def display_ind_parents(self, ppl_handle_list): def display_ind_parents(self):
""" """
Display a person's parents Display a person's parents
""" """
@ -6192,8 +6195,6 @@ class IndividualPage(BasePage):
if not parent_list: if not parent_list:
return None return None
birthorder = self.report.options['birthorder']
# begin parents division # begin parents division
with Html("div", class_ = "subsection", id = "parents") as section: with Html("div", class_ = "subsection", id = "parents") as section:
section += Html("h4", _("Parents"), inline = True) section += Html("h4", _("Parents"), inline = True)
@ -6210,7 +6211,7 @@ class IndividualPage(BasePage):
# Get the mother and father relationships # Get the mother and father relationships
frel = None frel = None
mrel = None mrel = None
sibling = [] all_children = []
child_handle = self.person.get_handle() child_handle = self.person.get_handle()
child_ref_list = family.get_child_ref_list() child_ref_list = family.get_child_ref_list()
@ -6252,38 +6253,10 @@ class IndividualPage(BasePage):
if len(child_ref_list) > 1: if len(child_ref_list) > 1:
# remove sibling if it is yourself? # remove sibling if it is yourself?
childlist = [child_ref.ref for child_ref in child_ref_list child_list = [child_ref.ref for child_ref in child_ref_list
if child_ref.ref != self.person.handle] if child_ref.ref != self.person.get_handle()]
sibling.extend(childlist) all_children.extend(child_list)
# now that we have all siblings in families of the person,
# display them...
if sibling:
trow = Html("tr") + (
Html("td", _("Siblings"), class_ = "ColumnAttribute", inline = True)
)
table += trow
tcell = Html("td", class_ = "ColumnValue")
trow += tcell
ordered = Html("ol")
tcell += ordered
sibling = add_birthdate(self.dbase_, sibling)
if birthorder:
sibling = sorted(sibling)
ordered.extend(
self.display_child_link(chandle, ppl_handle_list)
for birth_date, chandle in sibling
)
# Also try to identify half-siblings
half_siblings = []
## FOLLOWING CODE IS WRONG, AS showallsiblings = False
## THIS CODE WILL NOT RUN
## TO FIX: the code only works if the user has his ## TO FIX: the code only works if the user has his
## half/step siblings in a specific way in the database, ## half/step siblings in a specific way in the database,
## however this way is not the official way ## however this way is not the official way
@ -6293,145 +6266,187 @@ class IndividualPage(BasePage):
## here over other families is wrong ## here over other families is wrong
## 2. to determine the relationship, only the child ## 2. to determine the relationship, only the child
## relationship must be looked at, nothing else! ## relationship must be looked at, nothing else!
showallsiblings = False #self.report.options['showhalfsiblings'] showallsiblings = self.report.options['showhalfsiblings']
## # if we have a known father... # if we have a known father...
## if father_handle and showallsiblings: if father_handle and showallsiblings:
## # 1) get all of the families in which this father is involved # 1) get all of the families in which this father is involved
## # 2) get all of the children from those families # 2) get all of the children from those families
## # 3) if the children are not already listed as siblings... # 3) if the children are not already listed as siblings...
## # 4) then remember those children since we're going to list them # 4) then remember those children since we're going to list them
## father = self.dbase_.get_person_from_handle(father_handle) father = self.dbase_.get_person_from_handle(father_handle)
## for family_handle in father.get_family_handle_list(): for family_handle in father.get_family_handle_list():
## family = self.dbase_.get_family_from_handle(family_handle) family = self.dbase_.get_family_from_handle(family_handle)
## for half_child_ref in family.get_child_ref_list(): for child_ref in family.get_child_ref_list():
## half_child_handle = half_child_ref.ref child_handle = child_ref.ref
## if half_child_handle not in sibling: if child_handle not in all_children:
## if half_child_handle != self.person.handle: if child_handle != self.person.get_handle():
## # we have a new step/half sibling all_children.append(child_handle)
## half_siblings.append(half_child_handle)
## # do the same thing with the mother (see "father" just above):
## # do the same thing with the mother (see "father" just above): if mother_handle and showallsiblings:
## if mother_handle and showallsiblings: mother = self.dbase_.get_person_from_handle(mother_handle)
## mother = self.dbase_.get_person_from_handle(mother_handle) for family_handle in mother.get_family_handle_list():
## for family_handle in mother.get_family_handle_list(): family = self.dbase_.get_family_from_handle(family_handle)
## family = self.dbase_.get_family_from_handle(family_handle) for child_ref in family.get_child_ref_list():
## for half_child_ref in family.get_child_ref_list(): child_handle = child_ref.ref
## half_child_handle = half_child_ref.ref if child_handle not in all_children:
## if half_child_handle not in sibling: if child_handle != self.person.get_handle():
## if half_child_handle != self.person.handle: all_children.append(child_handle)
## # we have a new half sibling
## half_siblings.append(half_child_handle) if showallsiblings:
##
## # now that we have all half- siblings, display them... # to find the step-siblings, we need to identify
## if half_siblings: # all of the families that can be linked back to
## trow = Html("tr") + ( # the current person, and then extract the children
## Html("td", _("Half Siblings"), class_ = "ColumnAttribute", inline = True) # from those families
## ) all_family_handles = set()
## table += trow all_parent_handles = set()
## tmp_parent_handles = set()
## tcell = Html("td", class_ = "ColumnValue")
## trow += tcell # first we queue up the parents we know about
## if mother_handle:
## ordered = Html("ol") tmp_parent_handles.add(mother_handle)
## tcell += ordered if father_handle:
## tmp_parent_handles.add(father_handle)
## half_siblings = add_birthdate(self.dbase_, half_siblings)
## if birthorder: while len(tmp_parent_handles):
## half_siblings = sorted(half_siblings) # pop the next parent from the set
## parent_handle = tmp_parent_handles.pop()
## ordered.extend(
## self.display_child_link(chandle, ind_list) # add this parent to our official list
## for birth_date, chandle in half_siblings all_parent_handles.add(parent_handle)
## )
## # get all families with this parent
## # get step-siblings parent = self.dbase_.get_person_from_handle(parent_handle)
## if showallsiblings: for family_handle in parent.get_family_handle_list():
## step_siblings = []
## all_family_handles.add(family_handle)
## # to find the step-siblings, we need to identify
## # all of the families that can be linked back to # we already have 1 parent from this family
## # the current person, and then extract the children # (see "parent" above) so now see if we need
## # from those families # to queue up the other parent
## all_family_handles = set() family = self.dbase_.get_family_from_handle(family_handle)
## all_parent_handles = set() tmp_mother_handle = family.get_mother_handle()
## tmp_parent_handles = set() if tmp_mother_handle and \
## tmp_mother_handle != parent and \
## # first we queue up the parents we know about tmp_mother_handle not in tmp_parent_handles and \
## if mother_handle: tmp_mother_handle not in all_parent_handles:
## tmp_parent_handles.add(mother_handle) tmp_parent_handles.add(tmp_mother_handle)
## if father_handle:
## tmp_parent_handles.add(father_handle) tmp_father_handle = family.get_father_handle()
## if tmp_father_handle and \
## while len(tmp_parent_handles): tmp_father_handle != parent and \
## # pop the next parent from the set tmp_father_handle not in tmp_parent_handles and \
## parent_handle = tmp_parent_handles.pop() tmp_father_handle not in all_parent_handles:
## tmp_parent_handles.add(tmp_father_handle)
## # add this parent to our official list
## all_parent_handles.add(parent_handle) # once we get here, we have all of the families
## # that could result in step-siblings; note that
## # get all families with this parent # we can only have step-siblings if the number
## parent = self.dbase_.get_person_from_handle(parent_handle) # of families involved is > 1
## for family_handle in parent.get_family_handle_list():
## if len(all_family_handles) > 1:
## all_family_handles.add(family_handle) while len(all_family_handles):
## # pop the next family from the set
## # we already have 1 parent from this family family_handle = all_family_handles.pop()
## # (see "parent" above) so now see if we need # look in this family for children we haven't yet seen
## # to queue up the other parent family = self.dbase_.get_family_from_handle(family_handle)
## family = self.dbase_.get_family_from_handle(family_handle) for child_ref in family.get_child_ref_list():
## tmp_mother_handle = family.get_mother_handle() child_handle = child_ref.ref
## if tmp_mother_handle and \ if child_handle not in all_children and \
## tmp_mother_handle != parent and \ child_handle != self.person.get_handle():
## tmp_mother_handle not in tmp_parent_handles and \ all_children.append(child_handle)
## tmp_mother_handle not in all_parent_handles:
## tmp_parent_handles.add(tmp_mother_handle) child_list = [child_handle for child_handle in all_children]
## tmp_father_handle = family.get_father_handle()
## if tmp_father_handle and \ # separate all children into biological, half, and step- siblings...
## tmp_father_handle != parent and \ siblings, half_siblings, step_siblings = [], [], []
## tmp_father_handle not in tmp_parent_handles and \
## tmp_father_handle not in all_parent_handles: if len(child_list):
## tmp_parent_handles.add(tmp_father_handle) for sibling_handle in child_list:
## sibling = self.dbase_.get_person_from_handle(sibling_handle)
## # once we get here, we have all of the families if sibling:
## # that could result in step-siblings; note that sibling_type = self.rel_class.get_sibling_type(
## # we can only have step-siblings if the number self.dbase_, self.person, sibling)
## # of families involved is > 1
## # biological/ natural sibling
## if len(all_family_handles) > 1: if sibling_type == 0:
## while len(all_family_handles): siblings.append(sibling_handle)
## # pop the next family from the set
## family_handle = all_family_handles.pop() # half siblings
## # look in this family for children we haven't yet seen elif (sibling_type == 1 or sibling_type == 2):
## family = self.dbase_.get_family_from_handle(family_handle) half_siblings.append(sibling_handle)
## for step_child_ref in family.get_child_ref_list():
## step_child_handle = step_child_ref.ref # step siblings
## if step_child_handle not in sibling and \ elif (sibling_type == 3 or sibling_type == 4):
## step_child_handle not in half_siblings and \ step_siblings.append(sibling_handle)
## step_child_handle != self.person.handle:
## # we have a new step sibling # now that we have all siblings, display them...
## step_siblings.append(step_child_handle) if len(siblings):
## trow = Html("tr") + (
## # now that we have all step- siblings, display them... Html("td", _("Siblings"), class_ = "ColumnAttribute", inline = True)
## if len(step_siblings): )
## trow = Html("tr") + ( table += trow
## Html("td", _("Step Siblings"), class_ = "ColumnAttribute", inline = True)
## ) tcell = Html("td", class_ = "ColumnValue")
## table += trow trow += tcell
##
## tcell = Html("td", class_ = "ColumnValue") ordered = Html("ol")
## trow += tcell tcell += ordered
##
## ordered = Html("ol") siblings = add_birthdate(self.dbase_, siblings)
## tcell += ordered if self.birthorder:
## siblings = sorted(siblings)
## step_siblings = add_birthdate(self.dbase_, step_siblings)
## if birthorder: ordered.extend(
## step_siblings = sorted(step_siblings) self.display_child_link(child_handle, self.ind_list)
## for birth_date, child_handle in siblings
## ordered.extend( )
## self.display_child_link(chandle, ind_list)
## for birth_date, chandle in step_siblings # now that we have all half- siblings, display them...
## ) if len(half_siblings):
trow = Html("tr") + (
Html("td", _("Half Siblings"), class_ = "ColumnAttribute", inline = True)
)
table += trow
tcell = Html("td", class_ = "ColumnValue")
trow += tcell
ordered = Html("ol")
tcell += ordered
half_siblings = add_birthdate(self.dbase_, half_siblings)
if self.birthorder:
half_siblings = sorted(half_siblings)
ordered.extend(
self.display_child_link(child_handle, self.ind_list)
for birth_date, child_handle in half_siblings
)
# now that we have all step- siblings, display them...
if len(step_siblings):
trow = Html("tr") + (
Html("td", _("Step Siblings"), class_ = "ColumnAttribute", inline = True)
)
table += trow
tcell = Html("td", class_ = "ColumnValue")
trow += tcell
ordered = Html("ol")
tcell += ordered
step_siblings = add_birthdate(self.dbase_, step_siblings)
if self.birthorder:
step_siblings = sorted(step_siblings)
ordered.extend(
self.display_child_link(child_handle, self.ind_list)
for birth_date, child_handle in step_siblings
)
# return parents division to its caller # return parents division to its caller
return section return section
@ -7962,11 +7977,11 @@ class NavWebOptions(MenuReportOptions):
showparents.set_help(_('Whether to include a parents column')) showparents.set_help(_('Whether to include a parents column'))
addopt( "showparents", showparents ) addopt( "showparents", showparents )
## showallsiblings = BooleanOption(_("Include half and/ or " showallsiblings = BooleanOption(_("Include half and/ or "
## "step-siblings on the individual pages"), False) "step-siblings on the individual pages"), False)
## showallsiblings.set_help(_( "Whether to include half and/ or " showallsiblings.set_help(_( "Whether to include half and/ or "
## "step-siblings with the parents and siblings")) "step-siblings with the parents and siblings"))
## addopt('showhalfsiblings', showallsiblings) addopt('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 or in entry order?')) birthorder.set_help(_('Whether to display children in birth order or in entry order?'))