Fixed the problem with the FamilyPage content not showing in the page. Added a conditional to MediaListPage to catch possible failure.
svn: r18080
This commit is contained in:
parent
bcbe23ebbb
commit
a9dc79c730
@ -34,9 +34,9 @@
|
|||||||
"""
|
"""
|
||||||
Narrative Web Page generator.
|
Narrative Web Page generator.
|
||||||
"""
|
"""
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
# python modules
|
# python modules
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
from functools import partial
|
from functools import partial
|
||||||
@ -66,15 +66,15 @@ import operator
|
|||||||
from decimal import Decimal, getcontext
|
from decimal import Decimal, getcontext
|
||||||
getcontext().prec = 8
|
getcontext().prec = 8
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
# Set up logging
|
# Set up logging
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(".NarrativeWeb")
|
log = logging.getLogger(".NarrativeWeb")
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
# GRAMPS module
|
# GRAMPS module
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
from gen.ggettext import sgettext as _
|
from gen.ggettext import sgettext as _
|
||||||
import gen.lib
|
import gen.lib
|
||||||
from gen.lib import UrlType, date, FamilyRelType, NoteType, EventRoleType
|
from gen.lib import UrlType, date, FamilyRelType, NoteType, EventRoleType
|
||||||
@ -114,9 +114,9 @@ from libgedcom import make_gedcom_date
|
|||||||
from PlaceUtils import conv_lat_lon
|
from PlaceUtils import conv_lat_lon
|
||||||
from gui.pluginmanager import GuiPluginManager
|
from gui.pluginmanager import GuiPluginManager
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
# constants
|
# constants
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------
|
||||||
# Translatable strings for variables within this plugin
|
# Translatable strings for variables within this plugin
|
||||||
# gettext carries a huge footprint with it.
|
# gettext carries a huge footprint with it.
|
||||||
AHEAD = _("Attributes")
|
AHEAD = _("Attributes")
|
||||||
@ -350,6 +350,7 @@ class BasePage(object):
|
|||||||
self.noid = report.options['nogid']
|
self.noid = report.options['nogid']
|
||||||
self.linkhome = report.options['linkhome']
|
self.linkhome = report.options['linkhome']
|
||||||
self.create_media = report.options['gallery']
|
self.create_media = report.options['gallery']
|
||||||
|
self.thumbpreview = report.options['thumbpreview']
|
||||||
self.inc_events = report.options['inc_events']
|
self.inc_events = report.options['inc_events']
|
||||||
|
|
||||||
def complete_people(self, tcell, first_person, handle_list, ppl_hnd_list, up =True):
|
def complete_people(self, tcell, first_person, handle_list, ppl_hnd_list, up =True):
|
||||||
@ -2573,9 +2574,9 @@ class SurnamePage(BasePage):
|
|||||||
if mother:
|
if mother:
|
||||||
mother_name = self.get_name(mother)
|
mother_name = self.get_name(mother)
|
||||||
if mother and father:
|
if mother and father:
|
||||||
tcell = ( Html("span", father_name, class_ = "father fatherNmother") +
|
tcell = Html("span", father_name, class_ = "father fatherNmother") + (
|
||||||
Html("span", mother_name, class_ = "mother")
|
Html("span", mother_name, class_ = "mother")
|
||||||
)
|
)
|
||||||
elif mother:
|
elif mother:
|
||||||
tcell = Html("span", mother_name, class_ = "mother", inline = True)
|
tcell = Html("span", mother_name, class_ = "mother", inline = True)
|
||||||
elif father:
|
elif father:
|
||||||
@ -2763,15 +2764,18 @@ class FamilyListPage(BasePage):
|
|||||||
|
|
||||||
class FamilyPage(BasePage):
|
class FamilyPage(BasePage):
|
||||||
def __init__(self, report, title, person, family, ppl_hnd_list):
|
def __init__(self, report, title, person, family, ppl_hnd_list):
|
||||||
|
if (not person or not family):
|
||||||
|
return
|
||||||
|
|
||||||
db = report.database
|
db = report.database
|
||||||
BasePage.__init__(self, report, title, family.get_gramps_id())
|
BasePage.__init__(self, report, title, family.get_gramps_id())
|
||||||
|
|
||||||
self.bibli = Bibliography()
|
self.bibli = Bibliography()
|
||||||
self.person = person
|
self.person = person
|
||||||
person_name = self.get_name(person)
|
self.up = True
|
||||||
|
birthorder = self.report.options["birthorder"]
|
||||||
|
|
||||||
of = self.report.create_file(family.get_handle(), "fam")
|
of = self.report.create_file(family.get_handle(), "fam")
|
||||||
self.up = True
|
|
||||||
familydetailpage, head, body = self.write_header(_("Family/ Relationship"))
|
familydetailpage, head, body = self.write_header(_("Family/ Relationship"))
|
||||||
|
|
||||||
partner = False
|
partner = False
|
||||||
@ -2783,7 +2787,7 @@ class FamilyPage(BasePage):
|
|||||||
with Html("div", class_ ="content", id ="RelationshipDetail") as familydetail:
|
with Html("div", class_ ="content", id ="RelationshipDetail") as familydetail:
|
||||||
body += familydetail
|
body += familydetail
|
||||||
|
|
||||||
# family media list
|
# family media list initial thumbnail
|
||||||
if self.create_media:
|
if self.create_media:
|
||||||
family_media_list = family.get_media_list()
|
family_media_list = family.get_media_list()
|
||||||
thumbnail = self.display_first_image_as_thumbnail(family_media_list, family)
|
thumbnail = self.display_first_image_as_thumbnail(family_media_list, family)
|
||||||
@ -2808,101 +2812,96 @@ class FamilyPage(BasePage):
|
|||||||
self.page_title = _("Family for %s" % person_link)
|
self.page_title = _("Family for %s" % person_link)
|
||||||
elif partner:
|
elif partner:
|
||||||
self.page_title = _("Family for %s" % partner_link)
|
self.page_title = _("Family for %s" % partner_link)
|
||||||
familydetail += Html("h3", self.page_title, inline =True)
|
familydetail += Html("h2", self.page_title, inline =True)
|
||||||
|
|
||||||
family_hnd_list = [family.get_handle()]
|
|
||||||
birthorder = self.report.options["birthorder"]
|
|
||||||
|
|
||||||
# begin families division and section title
|
# begin families division and section title
|
||||||
with Html("div", class_ = "subsection", id = "families") as section:
|
with Html("div", class_ = "subsection", id = "families") as section:
|
||||||
familydetail += Html("h4", _("Family"), inline =True)
|
familydetail += section
|
||||||
|
section += Html("h4", _("Family"), inline =True)
|
||||||
|
|
||||||
# begin families table
|
# begin families table
|
||||||
with Html("table", class_ ="infolist") as table:
|
with Html("table", class_ ="infolist") as table:
|
||||||
section += table
|
section += table
|
||||||
|
|
||||||
if family:
|
gender = self.person.get_gender()
|
||||||
gender = self.person.get_gender()
|
reltype = family.get_relationship()
|
||||||
reltype = family.get_relationship()
|
|
||||||
|
|
||||||
if reltype == gen.lib.FamilyRelType.MARRIED:
|
if reltype == gen.lib.FamilyRelType.MARRIED:
|
||||||
if gender == gen.lib.Person.FEMALE:
|
if gender == gen.lib.Person.FEMALE:
|
||||||
relstr = _("Husband")
|
relstr = _("Husband")
|
||||||
elif gender == gen.lib.Person.MALE:
|
elif gender == gen.lib.Person.MALE:
|
||||||
relstr = _("Wife")
|
relstr = _("Wife")
|
||||||
else:
|
|
||||||
relstr = _("Partner")
|
|
||||||
else:
|
else:
|
||||||
relstr = _("Partner")
|
relstr = _("Partner")
|
||||||
|
else:
|
||||||
|
relstr = _("Partner")
|
||||||
|
|
||||||
partner_handle = ReportUtils.find_spouse(self.person, family)
|
partner_handle = ReportUtils.find_spouse(self.person, family)
|
||||||
if partner_handle:
|
if partner_handle:
|
||||||
|
|
||||||
partner = db.get_person_from_handle(partner_handle)
|
partner = db.get_person_from_handle(partner_handle)
|
||||||
partner_name = self.get_name(partner)
|
partner_name = self.get_name(partner)
|
||||||
|
else:
|
||||||
|
partner_name = _("Unknown")
|
||||||
|
|
||||||
|
# family relationship type
|
||||||
|
rtype = str(family.get_relationship())
|
||||||
|
trow = Html("tr", class_ = "BeginFamily") + (
|
||||||
|
Html("td", rtype, class_ = "ColumnType", inline = True),
|
||||||
|
Html("td", relstr, class_ = "ColumnAttribute", inline = True)
|
||||||
|
)
|
||||||
|
table += trow
|
||||||
|
|
||||||
|
tcell = Html("td", class_ = "ColumnValue")
|
||||||
|
trow += tcell
|
||||||
|
|
||||||
|
# display partner's name
|
||||||
|
if partner_handle:
|
||||||
|
if check_person_database(partner_handle, ppl_hnd_list):
|
||||||
|
url = self.report.build_url_fname_html(partner_handle, "ppl", True)
|
||||||
|
tcell += self.person_link(url, partner, _NAME_STYLE_DEFAULT,
|
||||||
|
gid = partner.gramps_id)
|
||||||
else:
|
else:
|
||||||
partner_name = _("Unknown")
|
tcell += partner_name
|
||||||
|
else:
|
||||||
|
tcell += ' '
|
||||||
|
|
||||||
# family relationship type
|
# display family events; such as marriage and divorce events
|
||||||
rtype = str(family.get_relationship())
|
family_events = family.get_event_ref_list()
|
||||||
trow = Html("tr", class_ = "BeginFamily") + (
|
if family_events:
|
||||||
Html("td", rtype, class_ = "ColumnType", inline = True),
|
trow = Html("tr") + (
|
||||||
Html("td", relstr, class_ = "ColumnAttribute", inline = True)
|
Html("td", " ", class_ = "ColumnType", inline = True),
|
||||||
|
Html("td", " ", class_ = "ColumnAttribute", inline = True)
|
||||||
)
|
)
|
||||||
table += trow
|
table += trow
|
||||||
|
|
||||||
tcell = Html("td", class_ = "ColumnValue")
|
tcell = Html("td", class_ ="ColumnValue")
|
||||||
trow += tcell
|
trow += tcell
|
||||||
|
|
||||||
# display partner's name
|
childlist = family.get_child_ref_list()
|
||||||
if partner_handle:
|
if childlist:
|
||||||
if check_person_database(partner_handle, ppl_hnd_list):
|
|
||||||
url = self.report.build_url_fname_html(partner_handle, "ppl", True)
|
|
||||||
tcell += self.person_link(url, partner, _NAME_STYLE_DEFAULT,
|
|
||||||
gid = partner.gramps_id)
|
|
||||||
else:
|
|
||||||
tcell += partner_name
|
|
||||||
else:
|
|
||||||
tcell += ' '
|
|
||||||
|
|
||||||
# display family events; such as marriage and divorce events
|
|
||||||
family_events = family.get_event_ref_list()
|
|
||||||
if family_events:
|
|
||||||
trow = Html("tr") + (
|
trow = Html("tr") + (
|
||||||
Html("td", " ", class_ = "ColumnType", inline = True),
|
Html("td", " ", class_ = "ColumnType", inline = True),
|
||||||
Html("td", " ", class_ = "ColumnAttribute", inline = True)
|
Html("td", _("Children"), class_ = "ColumnAttribute", inline = True)
|
||||||
)
|
)
|
||||||
table += trow
|
table += trow
|
||||||
|
|
||||||
tcell = Html("td", class_ ="ColumnValue")
|
tcell = Html("td", class_ = "ColumnValue")
|
||||||
trow += tcell
|
trow += tcell
|
||||||
|
|
||||||
|
ordered = Html("ol")
|
||||||
|
tcell += ordered
|
||||||
|
|
||||||
|
childlist = [child_ref.ref for child_ref in childlist]
|
||||||
|
|
||||||
childlist = family.get_child_ref_list()
|
children = add_birthdate(db, childlist)
|
||||||
if childlist:
|
if birthorder:
|
||||||
trow = Html("tr") + (
|
children = sorted(children)
|
||||||
Html("td", " ", class_ = "ColumnType", inline = True),
|
|
||||||
Html("td", _("Children"), class_ = "ColumnAttribute", inline = True)
|
|
||||||
)
|
|
||||||
table += trow
|
|
||||||
|
|
||||||
tcell = Html("td", class_ = "ColumnValue")
|
ordered.extend(
|
||||||
trow += tcell
|
self.display_child_link(chandle, ppl_hnd_list)
|
||||||
|
for birth_date, chandle in children
|
||||||
ordered = Html("ol")
|
)
|
||||||
tcell += ordered
|
|
||||||
|
|
||||||
childlist = [child_ref.ref for child_ref in childlist]
|
|
||||||
|
|
||||||
children = add_birthdate(db, childlist)
|
|
||||||
if birthorder:
|
|
||||||
children = sorted(children)
|
|
||||||
|
|
||||||
ordered.extend(
|
|
||||||
self.display_child_link(chandle, ppl_hnd_list)
|
|
||||||
for birth_date, chandle in children
|
|
||||||
)
|
|
||||||
|
|
||||||
# display family LDS ordinance...
|
# display family LDS ordinance...
|
||||||
disp_fam_lds = self.display_lds_ordinance(family)
|
disp_fam_lds = self.display_lds_ordinance(family)
|
||||||
@ -4131,7 +4130,6 @@ class SourcePage(BasePage):
|
|||||||
self.XHTMLWriter(sourcepage, of)
|
self.XHTMLWriter(sourcepage, of)
|
||||||
|
|
||||||
class MediaListPage(BasePage):
|
class MediaListPage(BasePage):
|
||||||
|
|
||||||
def __init__(self, report, title):
|
def __init__(self, report, title):
|
||||||
BasePage.__init__(self, report, title)
|
BasePage.__init__(self, report, title)
|
||||||
db = report.database
|
db = report.database
|
||||||
@ -4160,16 +4158,15 @@ class MediaListPage(BasePage):
|
|||||||
|
|
||||||
trow = Html("tr")
|
trow = Html("tr")
|
||||||
thead += trow
|
thead += trow
|
||||||
media_header_row = [
|
|
||||||
[" ", "RowLabel"],
|
|
||||||
[_("Media | Name"), "Name"],
|
|
||||||
[DHEAD, "Date"],
|
|
||||||
[_("Mime Type"), "Mime"]
|
|
||||||
]
|
|
||||||
trow.extend(
|
trow.extend(
|
||||||
Html("th", label, class_ = "Column" + colclass, inline = True)
|
Html("th", trans, class_ =colclass, inline =True)
|
||||||
for (label, colclass) in media_header_row
|
for trans, colclass in [
|
||||||
)
|
[" ", "ColumnRowLabel"],
|
||||||
|
[_("Media | Name"), "ColumnName"],
|
||||||
|
[_("Date"), "ColumnDate"],
|
||||||
|
[_("Mime Type"), "ColumnMime"] ]
|
||||||
|
)
|
||||||
|
|
||||||
# begin table body
|
# begin table body
|
||||||
tbody = Html("tbody")
|
tbody = Html("tbody")
|
||||||
@ -4181,24 +4178,23 @@ class MediaListPage(BasePage):
|
|||||||
|
|
||||||
for handle in mlist:
|
for handle in mlist:
|
||||||
media = db.get_object_from_handle(handle)
|
media = db.get_object_from_handle(handle)
|
||||||
title = media.get_description() or "[untitled]"
|
if media:
|
||||||
|
title = media.get_description() or "[untitled]"
|
||||||
|
|
||||||
trow = Html("tr")
|
trow = Html("tr")
|
||||||
tbody += trow
|
tbody += trow
|
||||||
|
|
||||||
media_data_row = [
|
media_data_row = [
|
||||||
[index, "RowLabel"],
|
[index, "RowLabel"],
|
||||||
[self.media_ref_link(handle, title), "Name"],
|
[self.media_ref_link(handle, title), "Name"],
|
||||||
[_dd.display(media.get_date_object() ), "Date"],
|
[_dd.display(media.get_date_object() ), "Date"],
|
||||||
[media.get_mime_type(), "Mime"]
|
[media.get_mime_type(), "Mime"] ]
|
||||||
]
|
|
||||||
|
|
||||||
trow.extend(
|
trow.extend(
|
||||||
Html("td", data, class_ = "Column" + colclass)
|
Html("td", data, class_ =colclass)
|
||||||
for (data, colclass) in media_data_row
|
for data, colclass in media_data_row
|
||||||
)
|
)
|
||||||
|
index += 1
|
||||||
index += 1
|
|
||||||
|
|
||||||
# add footer section
|
# add footer section
|
||||||
# add clearline for proper styling
|
# add clearline for proper styling
|
||||||
@ -6057,13 +6053,16 @@ class NavWebReport(Report):
|
|||||||
|
|
||||||
self.title = self.options['title']
|
self.title = self.options['title']
|
||||||
self.inc_gallery = self.options['gallery']
|
self.inc_gallery = self.options['gallery']
|
||||||
|
self.thumbpreview = self.options['thumbpreview']
|
||||||
|
|
||||||
self.inc_contact = self.options['contactnote'] or \
|
self.inc_contact = self.options['contactnote'] or \
|
||||||
self.options['contactimg']
|
self.options['contactimg']
|
||||||
|
|
||||||
# name format options
|
# name format options
|
||||||
self.name_format = self.options['name_format']
|
self.name_format = self.options['name_format']
|
||||||
|
|
||||||
# create family pages or not?
|
# create a media thumbnail preview page or not?
|
||||||
|
self.thumbpreview = self.options['thumbpreview']
|
||||||
|
|
||||||
# create an event pages or not?
|
# create an event pages or not?
|
||||||
self.inc_events = self.options['inc_events']
|
self.inc_events = self.options['inc_events']
|
||||||
@ -7000,7 +6999,7 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
"\nIf no publisher information is given,"
|
"\nIf no publisher information is given,"
|
||||||
"\nno contact page will be created")
|
"\nno contact page will be created")
|
||||||
)
|
)
|
||||||
addopt( "contactimg", contactimg )
|
addopt("contactimg", contactimg)
|
||||||
|
|
||||||
headernote = NoteOption(_('HTML user header'))
|
headernote = NoteOption(_('HTML user header'))
|
||||||
headernote.set_help( _("A note to be used as the page header"))
|
headernote.set_help( _("A note to be used as the page header"))
|
||||||
@ -7015,6 +7014,11 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
addopt( "gallery", self.__gallery )
|
addopt( "gallery", self.__gallery )
|
||||||
self.__gallery.connect('value-changed', self.__gallery_changed)
|
self.__gallery.connect('value-changed', self.__gallery_changed)
|
||||||
|
|
||||||
|
self.__thumbpreview = BooleanOption(_("Create a media thumbnails preview page"), False)
|
||||||
|
self.__thumbpreview.set_help(_("Whether to create a thumbnail's preview page? "
|
||||||
|
"This will be hyper- linked to the Media List Page only!"))
|
||||||
|
addopt("thumbpreview", self.__thumbpreview)
|
||||||
|
|
||||||
self.__maxinitialimagewidth = NumberOption(_("Max width of initial image"),
|
self.__maxinitialimagewidth = NumberOption(_("Max width of initial image"),
|
||||||
_DEFAULT_MAX_IMG_WIDTH, 0, 2000)
|
_DEFAULT_MAX_IMG_WIDTH, 0, 2000)
|
||||||
self.__maxinitialimagewidth.set_help(_("This allows you to set the maximum width "
|
self.__maxinitialimagewidth.set_help(_("This allows you to set the maximum width "
|
||||||
@ -7025,7 +7029,7 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
_DEFAULT_MAX_IMG_HEIGHT, 0, 2000)
|
_DEFAULT_MAX_IMG_HEIGHT, 0, 2000)
|
||||||
self.__maxinitialimageheight.set_help(_("This allows you to set the maximum height "
|
self.__maxinitialimageheight.set_help(_("This allows you to set the maximum height "
|
||||||
"of the image shown on the media page. Set to 0 for no limit."))
|
"of the image shown on the media page. Set to 0 for no limit."))
|
||||||
addopt( "maxinitialimageheight", self.__maxinitialimageheight )
|
addopt( "maxinitialimageheight", self.__maxinitialimageheight)
|
||||||
|
|
||||||
self.__gallery_changed()
|
self.__gallery_changed()
|
||||||
|
|
||||||
@ -7264,10 +7268,15 @@ class NavWebOptions(MenuReportOptions):
|
|||||||
Handles the changing nature of gallery
|
Handles the changing nature of gallery
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if self.__gallery.get_value() == False:
|
if not self.__gallery.get_value():
|
||||||
|
self.__thumbpreview.set_available(False)
|
||||||
|
|
||||||
|
|
||||||
self.__maxinitialimagewidth.set_available(False)
|
self.__maxinitialimagewidth.set_available(False)
|
||||||
self.__maxinitialimageheight.set_available(False)
|
self.__maxinitialimageheight.set_available(False)
|
||||||
else:
|
else:
|
||||||
|
self.__thumbpreview.set_available(True)
|
||||||
|
|
||||||
self.__maxinitialimagewidth.set_available(True)
|
self.__maxinitialimagewidth.set_available(True)
|
||||||
self.__maxinitialimageheight.set_available(True)
|
self.__maxinitialimageheight.set_available(True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user