Fixedclasses FamilyListPage and FamilyPage.
svn: r18799
This commit is contained in:
parent
431ae7b8c2
commit
b26fe55a66
@ -990,6 +990,56 @@ class BasePage(object):
|
|||||||
hyper += Html("span", " [%s]" % gid, class_ = "grampsid", inline = True)
|
hyper += Html("span", " [%s]" % gid, class_ = "grampsid", inline = True)
|
||||||
return hyper
|
return hyper
|
||||||
|
|
||||||
|
def get_family_link(self, family, ppl_handle_list, type_ = "Html"):
|
||||||
|
"""
|
||||||
|
returns the husband and spouse link...
|
||||||
|
"""
|
||||||
|
husband, spouse = [None]*2
|
||||||
|
|
||||||
|
husband_handle = family.get_father_handle()
|
||||||
|
spouse_handle = family.get_mother_handle()
|
||||||
|
|
||||||
|
if (husband_handle and husband_handle in ppl_handle_list):
|
||||||
|
husband = self.dbase_.get_person_from_handle(husband_handle)
|
||||||
|
if husband:
|
||||||
|
husband_name = self.get_name(husband)
|
||||||
|
|
||||||
|
if type_ == "String":
|
||||||
|
url = self.report.build_url_fname_html(husband_handle, 'ppl', up = self.up)
|
||||||
|
husband_link = self.person_link(url, husband, _NAME_STYLE_DEFAULT, gid = husband.get_gramps_id())
|
||||||
|
else:
|
||||||
|
husband_link = self.family_link(family.get_handle(), husband_name, family.get_gramps_id(), self.up)
|
||||||
|
|
||||||
|
if (spouse_handle and spouse_handle in ppl_handle_list):
|
||||||
|
spouse = self.dbase_.get_person_from_handle(spouse_handle)
|
||||||
|
if spouse:
|
||||||
|
spouse_name = self.get_name(spouse)
|
||||||
|
|
||||||
|
if type_ == "String":
|
||||||
|
url = self.report.build_url_fname_html(spouse_handle, 'ppl', up = self.up)
|
||||||
|
spouse_link = self.person_link(url, spouse, _NAME_STYLE_DEFAULT, gid = spouse.get_gramps_id())
|
||||||
|
else:
|
||||||
|
spouse_link = self.family_link(family.get_handle(), spouse_name, family.get_gramps_id(), self.up)
|
||||||
|
|
||||||
|
# return Html instead of a string...
|
||||||
|
if type_ == "Html":
|
||||||
|
web_link = Html("li")
|
||||||
|
if spouse and husband:
|
||||||
|
web_link += 'H%s ' % husband_link + _("and") + ' %s' % spouse_link
|
||||||
|
elif spouse:
|
||||||
|
web_link += spouse_link
|
||||||
|
elif husband:
|
||||||
|
web_link += husband_link
|
||||||
|
return web_link
|
||||||
|
else:
|
||||||
|
if husband and spouse:
|
||||||
|
self.page_title += "%s and %s" % (husband_link, spouse_link)
|
||||||
|
elif husband:
|
||||||
|
self.page_title += "%s" % husband_link
|
||||||
|
elif spouse:
|
||||||
|
self.page_title += "%s" % spouse_link
|
||||||
|
return self.page_title
|
||||||
|
|
||||||
def event_link(self, event_handle, event_title, gid = None, uplink = False):
|
def event_link(self, event_handle, event_title, gid = None, uplink = False):
|
||||||
"""
|
"""
|
||||||
creates a hyperlink for an event based on its type
|
creates a hyperlink for an event based on its type
|
||||||
@ -3059,7 +3109,7 @@ class SurnamePage(BasePage):
|
|||||||
self.XHTMLWriter(surnamepage, of)
|
self.XHTMLWriter(surnamepage, of)
|
||||||
|
|
||||||
class FamilyListPage(BasePage):
|
class FamilyListPage(BasePage):
|
||||||
def __init__(self, report, title, ind_list, displayed):
|
def __init__(self, report, title, ind_list):
|
||||||
self.dbase_ = report.database
|
self.dbase_ = report.database
|
||||||
BasePage.__init__(self, report, title)
|
BasePage.__init__(self, report, title)
|
||||||
|
|
||||||
@ -3121,91 +3171,87 @@ class FamilyListPage(BasePage):
|
|||||||
for phandle in handle_list:
|
for phandle in handle_list:
|
||||||
person = self.dbase_.get_person_from_handle(phandle)
|
person = self.dbase_.get_person_from_handle(phandle)
|
||||||
if person:
|
if person:
|
||||||
if phandle not in displayed:
|
family_handle_list = person.get_family_handle_list()
|
||||||
|
if family_handle_list:
|
||||||
|
|
||||||
family_handle_list = person.get_family_handle_list()
|
first_family = True
|
||||||
if family_handle_list:
|
for fhandle in family_handle_list:
|
||||||
|
|
||||||
first_family = True
|
family = self.dbase_.get_family_from_handle(fhandle)
|
||||||
for fhandle in family_handle_list:
|
if family:
|
||||||
|
|
||||||
family = self.dbase_.get_family_from_handle(fhandle)
|
trow = Html("tr")
|
||||||
if family:
|
tbody += trow
|
||||||
|
|
||||||
trow = Html("tr")
|
tcell = Html("td", class_ ="ColumnRowLabel")
|
||||||
tbody += trow
|
trow += tcell
|
||||||
|
|
||||||
tcell = Html("td", class_ ="ColumnRowLabel")
|
if letter not in ltrs_displayed:
|
||||||
trow += tcell
|
trow.attr = 'class ="BeginLetter"'
|
||||||
|
tcell += Html("a", letter, name =letter,
|
||||||
|
title ="Families beginning with letter " + letter, inline =True)
|
||||||
|
|
||||||
if letter not in ltrs_displayed:
|
ltrs_displayed[letter] = True
|
||||||
trow.attr = 'class ="BeginLetter"'
|
else:
|
||||||
tcell += Html("a", letter, name =letter,
|
tcell += ' '
|
||||||
title ="Families beginning with letter " + letter, inline =True)
|
|
||||||
|
|
||||||
ltrs_displayed[letter] = True
|
tcell = Html("td", class_ ="ColumnPartner")
|
||||||
else:
|
trow += tcell
|
||||||
tcell += ' '
|
|
||||||
|
|
||||||
tcell = Html("td", class_ ="ColumnPartner")
|
if first_family:
|
||||||
trow += tcell
|
trow.attr = 'class ="BeginFamily"'
|
||||||
|
|
||||||
if first_family:
|
|
||||||
trow.attr = 'class ="BeginFamily"'
|
|
||||||
|
|
||||||
tcell += self.family_link(fhandle, self.get_name(person),
|
tcell += self.family_link(fhandle, self.get_name(person),
|
||||||
family.get_gramps_id(), self.up)
|
family.get_gramps_id(), self.up)
|
||||||
|
|
||||||
first_family = False
|
|
||||||
else:
|
|
||||||
tcell += ' '
|
|
||||||
|
|
||||||
tcell = Html("td", class_ ="ColumnPartner")
|
|
||||||
trow += tcell
|
|
||||||
|
|
||||||
# get partner if there is one listed?
|
|
||||||
partner_handle = ReportUtils.find_spouse(person, family)
|
|
||||||
if partner_handle:
|
|
||||||
partner = self.dbase_.get_person_from_handle(partner_handle)
|
|
||||||
if partner:
|
|
||||||
displayed.add(partner_handle)
|
|
||||||
use_link = check_person_database(partner_handle, ind_list)
|
|
||||||
if use_link:
|
|
||||||
tcell += self.family_link(fhandle, self.get_name(partner),
|
|
||||||
family.get_gramps_id(), self.up)
|
|
||||||
else:
|
|
||||||
tcell += self.get_name(partner)
|
|
||||||
else:
|
|
||||||
tcell += ' '
|
|
||||||
|
|
||||||
# family events; such as marriage and divorce events
|
|
||||||
fam_evt_ref_list = family.get_event_ref_list()
|
|
||||||
tcell1 = Html("td", class_ ="ColumnDate", inline =True)
|
|
||||||
tcell2 = Html("td", class_ ="ColumnDate", inline =True)
|
|
||||||
trow += (tcell1, tcell2)
|
|
||||||
|
|
||||||
if fam_evt_ref_list:
|
|
||||||
for evt_ref in fam_evt_ref_list:
|
|
||||||
event = self.dbase_.get_event_from_handle(evt_ref.ref)
|
|
||||||
if event:
|
|
||||||
evt_type = event.get_type()
|
|
||||||
if evt_type in [gen.lib.EventType.MARRIAGE,
|
|
||||||
gen.lib.EventType.DIVORCE]:
|
|
||||||
|
|
||||||
if evt_type == gen.lib.EventType.MARRIAGE:
|
|
||||||
tcell1 += _dd.display(event.get_date_object())
|
|
||||||
else:
|
|
||||||
tcell1 += ' '
|
|
||||||
|
|
||||||
if evt_type == gen.lib.EventType.DIVORCE:
|
|
||||||
tcell2 += _dd.display(event.get_date_object())
|
|
||||||
else:
|
|
||||||
tcell2 += ' '
|
|
||||||
else:
|
|
||||||
tcell1 += ' '
|
|
||||||
tcell2 += ' '
|
|
||||||
first_family = False
|
first_family = False
|
||||||
displayed.add(phandle)
|
else:
|
||||||
|
tcell += ' '
|
||||||
|
|
||||||
|
tcell = Html("td", class_ ="ColumnPartner")
|
||||||
|
trow += tcell
|
||||||
|
|
||||||
|
# get partner if there is one listed?
|
||||||
|
partner_handle = ReportUtils.find_spouse(person, family)
|
||||||
|
if partner_handle:
|
||||||
|
partner = self.dbase_.get_person_from_handle(partner_handle)
|
||||||
|
if partner:
|
||||||
|
use_link = check_person_database(partner_handle, ind_list)
|
||||||
|
if use_link:
|
||||||
|
tcell += self.family_link(fhandle, self.get_name(partner),
|
||||||
|
family.get_gramps_id(), self.up)
|
||||||
|
else:
|
||||||
|
tcell += self.get_name(partner)
|
||||||
|
else:
|
||||||
|
tcell += ' '
|
||||||
|
|
||||||
|
# family events; such as marriage and divorce events
|
||||||
|
fam_evt_ref_list = family.get_event_ref_list()
|
||||||
|
tcell1 = Html("td", class_ ="ColumnDate", inline =True)
|
||||||
|
tcell2 = Html("td", class_ ="ColumnDate", inline =True)
|
||||||
|
trow += (tcell1, tcell2)
|
||||||
|
|
||||||
|
if fam_evt_ref_list:
|
||||||
|
for evt_ref in fam_evt_ref_list:
|
||||||
|
event = self.dbase_.get_event_from_handle(evt_ref.ref)
|
||||||
|
if event:
|
||||||
|
evt_type = event.get_type()
|
||||||
|
if evt_type in [gen.lib.EventType.MARRIAGE,
|
||||||
|
gen.lib.EventType.DIVORCE]:
|
||||||
|
|
||||||
|
if evt_type == gen.lib.EventType.MARRIAGE:
|
||||||
|
tcell1 += _dd.display(event.get_date_object())
|
||||||
|
else:
|
||||||
|
tcell1 += ' '
|
||||||
|
|
||||||
|
if evt_type == gen.lib.EventType.DIVORCE:
|
||||||
|
tcell2 += _dd.display(event.get_date_object())
|
||||||
|
else:
|
||||||
|
tcell2 += ' '
|
||||||
|
else:
|
||||||
|
tcell1 += ' '
|
||||||
|
tcell2 += ' '
|
||||||
|
first_family = False
|
||||||
|
|
||||||
# add clearline for proper styling
|
# add clearline for proper styling
|
||||||
# add footer section
|
# add footer section
|
||||||
@ -3217,16 +3263,15 @@ class FamilyListPage(BasePage):
|
|||||||
self.XHTMLWriter(familiesListPage, of)
|
self.XHTMLWriter(familiesListPage, of)
|
||||||
|
|
||||||
class FamilyPage(BasePage):
|
class FamilyPage(BasePage):
|
||||||
def __init__(self, report, title, person, family, place_list, ppl_handle_list, place_lat_long):
|
def __init__(self, report, title, family_handle, place_list, ppl_handle_list, place_lat_long):
|
||||||
if (not person or not family):
|
|
||||||
return
|
|
||||||
self.dbase_ = report.database
|
self.dbase_ = report.database
|
||||||
|
family = self.dbase_.get_family_from_handle(family_handle)
|
||||||
|
if not family:
|
||||||
|
return
|
||||||
|
BasePage.__init__(self, report, title, family.get_gramps_id())
|
||||||
|
|
||||||
self.bibli = Bibliography()
|
self.bibli = Bibliography()
|
||||||
self.person = person
|
|
||||||
self.place_list = place_list
|
self.place_list = place_list
|
||||||
|
|
||||||
BasePage.__init__(self, report, title, family.get_gramps_id())
|
|
||||||
self.up = True
|
self.up = True
|
||||||
|
|
||||||
birthorder = report.options["birthorder"]
|
birthorder = report.options["birthorder"]
|
||||||
@ -3235,53 +3280,49 @@ class FamilyPage(BasePage):
|
|||||||
of = self.report.create_file(family.get_handle(), "fam")
|
of = self.report.create_file(family.get_handle(), "fam")
|
||||||
familydetailpage, head, body = self.write_header(_("Family/ Relationship"))
|
familydetailpage, head, body = self.write_header(_("Family/ Relationship"))
|
||||||
|
|
||||||
partner = False
|
|
||||||
partner_handle = ReportUtils.find_spouse(person, family)
|
|
||||||
if partner_handle:
|
|
||||||
partner = self.dbase_.get_person_from_handle(partner_handle)
|
|
||||||
|
|
||||||
# begin FamilyDetaill division
|
# begin FamilyDetaill division
|
||||||
with Html("div", class_ ="content", id ="RelationshipDetail") as relationshipdetail:
|
with Html("div", class_ ="content", id ="RelationshipDetail") as relationshipdetail:
|
||||||
body += relationshipdetail
|
body += relationshipdetail
|
||||||
|
|
||||||
# family media list for initial thumbnail
|
# family media list for initial thumbnail
|
||||||
|
# delete thumbnail so that it won't display again in the Gallery List later on...
|
||||||
if self.create_media:
|
if self.create_media:
|
||||||
family_media_list = family.get_media_list()
|
media_list = family.get_media_list()
|
||||||
thumbnail = self.display_first_image_as_thumbnail(family_media_list, family)
|
thumbnail = self.display_first_image_as_thumbnail(media_list, family)
|
||||||
if thumbnail:
|
if thumbnail:
|
||||||
relationshipdetail += thumbnail
|
relationshipdetail += thumbnail
|
||||||
|
media_list.remove(media_list[0])
|
||||||
|
|
||||||
url = self.report.build_url_fname_html(person.get_handle(), 'ppl', up =self.up)
|
husband, spouse = [None]*2
|
||||||
person_link = self.person_link(url, person, _NAME_STYLE_DEFAULT, gid = person.get_gramps_id())
|
husband_handle = family.get_father_handle()
|
||||||
|
spouse_handle = family.get_mother_handle()
|
||||||
|
if husband_handle:
|
||||||
|
husband = self.dbase_.get_person_from_handle(husband_handle)
|
||||||
|
|
||||||
if partner:
|
if spouse_handle:
|
||||||
use_link = check_person_database(partner_handle, ppl_handle_list)
|
spouse = self.dbase_.get_person_from_handle(spouse_handle)
|
||||||
if use_link:
|
|
||||||
url = self.report.build_url_fname_html(partner_handle, 'ppl', up =self.up)
|
self.person = None
|
||||||
partner_link = self.person_link(url, partner, _NAME_STYLE_DEFAULT,
|
if husband and spouse:
|
||||||
gid = partner.get_gramps_id())
|
self.person = husband
|
||||||
else:
|
elif husband:
|
||||||
partner_link = self.get_name(partner)
|
self.person = husband
|
||||||
|
elif spouse_handle:
|
||||||
|
self.person = spouse
|
||||||
|
|
||||||
# determine if husband and wife, husband only, or spouse only....
|
# determine if husband and wife, husband only, or spouse only....
|
||||||
self.page_title = _("Family of ")
|
self.page_title = _("Family of ") + self.get_family_link(family, ppl_handle_list, type_ = "String")
|
||||||
if person and partner:
|
relationshipdetail += Html("h2", self.page_title, inline = True)
|
||||||
self.page_title += "%s and %s" % (person_link, partner_link)
|
|
||||||
elif person:
|
|
||||||
self.page_title += "%s" % person_link
|
|
||||||
elif partner:
|
|
||||||
self.page_title += "%s" % partner_link
|
|
||||||
relationshipdetail += Html("h2", self.page_title, inline =True)
|
|
||||||
|
|
||||||
|
|
||||||
# display relationships
|
# display relationships
|
||||||
families = self.display_relationships(self.person, ppl_handle_list, place_lat_long)
|
if self.person:
|
||||||
if families is not None:
|
families = self.display_relationships(self.person, ppl_handle_list, place_lat_long)
|
||||||
relationshipdetail += families
|
if families is not None:
|
||||||
|
relationshipdetail += families
|
||||||
|
|
||||||
# display additional images as gallery
|
# display additional images as gallery
|
||||||
if self.create_media:
|
if (self.create_media and media_list):
|
||||||
addgallery = self.display_additional_images_as_gallery(family_media_list, family)
|
addgallery = self.display_additional_images_as_gallery(media_list, family)
|
||||||
if addgallery:
|
if addgallery:
|
||||||
relationshipdetail += addgallery
|
relationshipdetail += addgallery
|
||||||
|
|
||||||
@ -4600,9 +4641,8 @@ class SourcePage(BasePage):
|
|||||||
family = self.dbase_.get_family_from_handle(family_handle)
|
family = self.dbase_.get_family_from_handle(family_handle)
|
||||||
if (family and family_handle in db_family_handles):
|
if (family and family_handle in db_family_handles):
|
||||||
ordered3.extend(
|
ordered3.extend(
|
||||||
self.__get_family_link(family, ppl_handle_list)
|
self.get_family_link(family, ppl_handle_list)
|
||||||
)
|
)
|
||||||
|
|
||||||
list2 += ordered3
|
list2 += ordered3
|
||||||
ordered2 += list2
|
ordered2 += list2
|
||||||
|
|
||||||
@ -4640,7 +4680,7 @@ class SourcePage(BasePage):
|
|||||||
family = self.dbase_.get_family_from_handle(newhandle)
|
family = self.dbase_.get_family_from_handle(newhandle)
|
||||||
if (family and newhandle in db_family_handles):
|
if (family and newhandle in db_family_handles):
|
||||||
ordered4.extend(
|
ordered4.extend(
|
||||||
self.__get_family_link(family, ppl_handle_list)
|
self.get_family_link(family, ppl_handle_list)
|
||||||
)
|
)
|
||||||
|
|
||||||
# any other event types...
|
# any other event types...
|
||||||
@ -4776,36 +4816,6 @@ class SourcePage(BasePage):
|
|||||||
# and close the file
|
# and close the file
|
||||||
self.XHTMLWriter(sourcepage, of)
|
self.XHTMLWriter(sourcepage, of)
|
||||||
|
|
||||||
def __get_family_link(self, family, ppl_handle_list):
|
|
||||||
"""
|
|
||||||
returns the husband and spouse link...
|
|
||||||
"""
|
|
||||||
husband, spouse = [None]*2
|
|
||||||
|
|
||||||
husband_handle = family.get_father_handle()
|
|
||||||
spouse_handle = family.get_mother_handle()
|
|
||||||
|
|
||||||
if (husband_handle and husband_handle in ppl_handle_list):
|
|
||||||
husband = self.dbase_.get_person_from_handle(husband_handle)
|
|
||||||
if husband:
|
|
||||||
husband_name = self.get_name(husband)
|
|
||||||
husband_link = self.family_link(family.get_handle(), husband_name, family.get_gramps_id(), self.up)
|
|
||||||
|
|
||||||
if (spouse_handle and spouse_handle in ppl_handle_list):
|
|
||||||
spouse = self.dbase_.get_person_from_handle(spouse_handle)
|
|
||||||
if spouse:
|
|
||||||
spouse_name = self.get_name(spouse)
|
|
||||||
spouse_link = self.family_link(family.get_handle(), spouse_name, family.get_gramps_id(), self.up)
|
|
||||||
|
|
||||||
web_link = Html("li")
|
|
||||||
if spouse and husband:
|
|
||||||
web_link += 'H%s' % husband_link + _("and") + '%s' % spouse_link
|
|
||||||
elif spouse:
|
|
||||||
web_link += spouse_link
|
|
||||||
elif husband:
|
|
||||||
web_link += husband_link
|
|
||||||
return web_link
|
|
||||||
|
|
||||||
class MediaListPage(BasePage):
|
class MediaListPage(BasePage):
|
||||||
def __init__(self, report, title):
|
def __init__(self, report, title):
|
||||||
self.dbase_ = report.database
|
self.dbase_ = report.database
|
||||||
@ -6962,7 +6972,7 @@ class NavWebReport(Report):
|
|||||||
|
|
||||||
# build classes FamilyListPage and FamilyPage
|
# build classes FamilyListPage and FamilyPage
|
||||||
if self.inc_families:
|
if self.inc_families:
|
||||||
self.family_pages(ind_list, place_list, place_lat_long)
|
self.family_pages(ind_list, place_list, place_lat_long, self.database.get_family_handles())
|
||||||
|
|
||||||
# build classes EventListPage and EventPage
|
# build classes EventListPage and EventPage
|
||||||
if self.inc_events:
|
if self.inc_events:
|
||||||
@ -7176,28 +7186,18 @@ class NavWebReport(Report):
|
|||||||
self.user.step_progress()
|
self.user.step_progress()
|
||||||
self.user.end_progress()
|
self.user.end_progress()
|
||||||
|
|
||||||
def family_pages(self, ppl_handle_list, place_list, place_lat_long):
|
def family_pages(self, ppl_handle_list, place_list, place_lat_long, db_family_handles):
|
||||||
"""
|
"""
|
||||||
creates the FamiliesListPage and FamilyPages
|
creates the FamiliesListPage and FamilyPages
|
||||||
"""
|
"""
|
||||||
displayed = set()
|
|
||||||
FamilyListPage(self, self.title, ppl_handle_list, displayed)
|
|
||||||
|
|
||||||
self.user.begin_progress(_("Narrated Web Site Report"),
|
self.user.begin_progress(_("Narrated Web Site Report"),
|
||||||
_("Creating family pages..."),
|
_("Creating family pages..."),
|
||||||
len(displayed))
|
self.database.get_number_of_families())
|
||||||
|
FamilyListPage(self, self.title, ppl_handle_list)
|
||||||
|
|
||||||
for phandle in ppl_handle_list:
|
for family_handle in db_family_handles:
|
||||||
person = self.database.get_person_from_handle(phandle)
|
FamilyPage(self, self.title, family_handle, place_list, ppl_handle_list, place_lat_long)
|
||||||
if person:
|
self.user.step_progress()
|
||||||
family_handle_list = person.get_family_handle_list()
|
|
||||||
if family_handle_list:
|
|
||||||
for fhandle in family_handle_list:
|
|
||||||
family = self.database.get_family_from_handle(fhandle)
|
|
||||||
if family:
|
|
||||||
FamilyPage(self, self.title, person, family, place_list, ppl_handle_list, place_lat_long)
|
|
||||||
|
|
||||||
self.user.step_progress()
|
|
||||||
self.user.end_progress()
|
self.user.end_progress()
|
||||||
|
|
||||||
def place_pages(self, place_list, source_list):
|
def place_pages(self, place_list, source_list):
|
||||||
|
Loading…
Reference in New Issue
Block a user