From 95ea123e01bb0cd8821363d6908fef5af1e10f75 Mon Sep 17 00:00:00 2001 From: "Rob G. Healey" Date: Sun, 22 Feb 2009 00:14:08 +0000 Subject: [PATCH] Add sort siblings to NarrativeWeb, and did some refactoring to WebCal with help from Gerald. svn: r12066 --- src/plugins/webreport/NarrativeWeb.py | 85 +++++++++++++++++++++++---- src/plugins/webreport/WebCal.py | 27 ++++----- 2 files changed, 87 insertions(+), 25 deletions(-) diff --git a/src/plugins/webreport/NarrativeWeb.py b/src/plugins/webreport/NarrativeWeb.py index 5c66ae4b9..4eae59162 100644 --- a/src/plugins/webreport/NarrativeWeb.py +++ b/src/plugins/webreport/NarrativeWeb.py @@ -101,8 +101,16 @@ from gen.lib.eventroletype import EventRoleType # constants # #------------------------------------------------------------------------ +# variables for alphabet_navigation _PERSON = 0 _PLACE = 1 + +# graphics for Maiz stylesheet +_WEBBKGD = 'Web_Mainz_Bkgd.png' +_WEBHEADER = 'Web_Mainz_Header.png' +_WEBMID = 'Web_Mainz_Mid.png' +_WEBMIDLIGHT = 'Web_Mainz_MidLight.png' + _INCLUDE_LIVING_VALUE = 99 # Arbitrary number _NAME_COL = 3 @@ -2432,6 +2440,8 @@ class IndividualPage(BasePage): # Also try to identify half-siblings half_siblings = set() + sort_half_sibs = [] + birthorder = self.report.options['birthorder'] # if we have a known father... showallsiblings = self.report.options['showhalfsiblings'] @@ -2450,6 +2460,18 @@ class IndividualPage(BasePage): # we have a new step/half sibling half_siblings.add(half_child_handle) + # if sort siblings or not? + if birthorder: + half_sib = db.get_person_from_handle(half_child_handle) + birth_ref = half_sib.get_birth_ref() + birth_date = None + if birth_ref: + birth_event = db.get_event_from_handle(birth_ref.ref) + birth_date = birth_event.get_date_object() + + if birth_date != None and birth_date.is_valid(): + sort_half_sibs.append((birth_date, half_child_handle)) + # do the same thing with the mother (see "father" just above): if mother_handle and showallsiblings: mother = db.get_person_from_handle(mother_handle) @@ -2462,20 +2484,39 @@ class IndividualPage(BasePage): # we have a new half sibling half_siblings.add(half_child_handle) + # sort siblings or not? + if birthorder: + half_sib = db.get_person_from_handle(half_child_handle) + birth_ref = half_sib.get_birth_ref() + birth_date = None + if birth_ref: + birth_event = db.get_event_from_handle(birth_ref.ref) + birth_date = birth_event.get_date_object() + + if birth_date != None and birth_date.is_valid(): + sort_half_sibs.append((birth_date, half_child_handle)) + # now that we have all of the half-siblings, print them out - if len(half_siblings) > 0: + if len(half_siblings) > 0 or len(sort_half_sibs) > 0: of.write('\t\t\t\n') of.write('\t\t\t\t%s\n' % _("Half Siblings")) of.write('\t\t\t\t\n') of.write('\t\t\t\t\t
    \n') - for child_handle in half_siblings: - self.display_child_link(of, child_handle) + if birthorder: + sort_half_sibs.sort() + + for date, handle in sort_half_sibs: + self.display_child_link(of, handle) + else: + for child_handle in half_siblings: + self.display_child_link(of, child_handle) of.write('\t\t\t\t\t
\n') of.write('\t\t\t\t\n') of.write('\t\t\t\n') # get step-siblings step_siblings = set() + step_kids = [] if showallsiblings: # to find the step-siblings, we need to identify @@ -2541,14 +2582,31 @@ class IndividualPage(BasePage): # we have a new step sibling step_siblings.add(step_child_handle) + # sort siblings or not? + if birthorder: + step_sib = db.get_person_from_handle(step_child_handle) + birth_ref = step_sib.get_birth_ref() + birth_date = None + if birth_ref: + birth_event = db.get_event_from_handle(birth_ref.ref) + birth_date = birth_event.get_date_object() + + if birth_date != None and birth_date.is_valid(): + step_kids.append((birth_date, step_child_handle)) + # now that we have all of the step-siblings, print them out - if len(step_siblings) > 0: + if len(step_siblings) > 0 or len(step_kids) > 0: of.write('\t\t\t\n') of.write('\t\t\t\t%s\n' % _("Step Siblings")) of.write('\t\t\t\t\n') of.write('\t\t\t\t\t
    \n') - for child_handle in step_siblings: - self.display_child_link(of, child_handle) + + if birthorder: + for date, handle in step_kids: + self.display_child_link(of, handle) + else: + for child_handle in step_siblings: + self.display_child_link(of, child_handle) of.write('\t\t\t\t\t
\n') of.write('\t\t\t\t\n') of.write('\t\t\t\n') @@ -2838,8 +2896,12 @@ class NavWebReport(Report): self.use_contact = self.options['contactnote'] or \ self.options['contactimg'] + # either include the gender graphics or not? self.graph = self.options['graph'] + # wether to sort all siblings by birthorder or not? + self.birthorder = self.options['birthorder'] + if self.use_home: self.index_fname = "index" self.surname_fname = "surnames" @@ -2976,11 +3038,7 @@ class NavWebReport(Report): # Copy Mainz Style Images if self.css == "Web_Mainz.css": - imgs += ["Web_Mainz_Bkgd.png", - "Web_Mainz_Header.png", - "Web_Mainz_Mid.png", - "Web_Mainz_MidLight.png", - "document.png"] + imgs += [_WEBBKGD, _WEBHEADER, _WEBMID, _WEBMIDLIGHT] # Copy the Creative Commons icon if the Creative Commons # license is requested??? @@ -3487,6 +3545,11 @@ class NavWebOptions(MenuReportOptions): "siblings")) menu.add_option(category_name, 'showhalfsiblings', showallsiblings) + birthorder = BooleanOption(_('Show all siblings in birth order'), False) + birthorder.set_help(_('Show all siblings including half/ Step in ' + 'birth order or not?')) + menu.add_option(category_name, 'birthorder', birthorder) + def __archive_changed(self): """ Update the change of storage: archive or directory diff --git a/src/plugins/webreport/WebCal.py b/src/plugins/webreport/WebCal.py index 36d8949ba..a762255c6 100644 --- a/src/plugins/webreport/WebCal.py +++ b/src/plugins/webreport/WebCal.py @@ -83,6 +83,12 @@ import libholiday # constants # #------------------------------------------------------------------------ +# Mainz stylesheet graphics +# will only be used if Mainz is slected as the stylesheet +_WEBBKGD = "Web_Mainz_Bkgd.png" +_WEBHEADER = "Web_Mainz_Header.png" +_WEBMID = "Web_Mainz_Mid.png" +_WEBMIDLIGHT = "Web_Mainz_MidLight.png" # This information defines the list of styles in the Web calendar # options dialog as well as the location of the corresponding SCREEN @@ -341,17 +347,13 @@ class WebCalReport(Report): if self.css == "Web_Mainz.css": # Copy Mainz Style Images - imgs += ["Web_Mainz_Bkgd.png", - "Web_Mainz_Header.png", - "Web_Mainz_Mid.png", - "Web_Mainz_MidLight.png", - ] + imgs += [_WEBBKGD, _WEBHEADER, _WEBMID, _WEBMIDLIGHT] # Copy GRAMPS favicon imgs += ['favicon.ico'] # copy copyright image - if 0 < self.copy < len(_CC): + if 0 < self.copy <= len(_CC): imgs += ['somerights20.gif'] for fname in imgs: @@ -1067,7 +1069,7 @@ class WebCalReport(Report): spouse_name = _get_short_name(spouse) short_name = _get_short_name(person) - are_married = get_marrital_status(self.database, fam) + are_married = get_marital_status(self.database, fam) if are_married is not None: for event_ref in fam.get_event_ref_list(): event = self.database.get_event_from_handle(event_ref.ref) @@ -1466,12 +1468,9 @@ def get_day_list(event_date, holiday_list, bday_anniv_list): # a birthday if event == 'Birthday': - if nyears == 0: - txt_str = _('%(person)s, birth') % { - 'person' : text} - else: - txt_str = _('%(person)s, %(age)s old') % { - 'person' : text, 'age' : age_str} + txt_str = _(text + ', ' + + ('birth' if nyears == 0 else '%s old' % str(age_str)) + + '') # an anniversary elif event == 'Anniversary': @@ -1496,7 +1495,7 @@ def get_day_list(event_date, holiday_list, bday_anniv_list): return day_list -def get_marrital_status(db, family): +def get_marital_status(db, family): """ Returns the marital status of two people, a couple