NarrativeWeb: Fixed place and dump_ordinance().

svn: r15637
This commit is contained in:
Rob G. Healey 2010-07-15 08:56:01 +00:00
parent d2d5be6919
commit 3567664f4c

View File

@ -705,10 +705,9 @@ class BasePage(object):
@param: ldsobj -- either person or family @param: ldsobj -- either person or family
@param: LDSSealedType = either Sealed to Family or Spouse @param: LDSSealedType = either Sealed to Family or Spouse
""" """
objectldsord = ldsobj.lds_ord_list objectldsord = ldsobj.get_lds_ord_list()
if not objectldsord: if not objectldsord:
return None return None
numberofords = len(objectldsord)
# begin LDS ordinance table and table head # begin LDS ordinance table and table head
with Html("table", class_ = "infolist ldsordlist") as table: with Html("table", class_ = "infolist ldsordlist") as table:
@ -719,42 +718,29 @@ class BasePage(object):
trow = Html("tr") trow = Html("tr")
thead += trow thead += trow
header_row = [ trow.extend(
Html("th", label, class_ = "Column" + colclass, inline = True)
for (label, colclass) in [
[THEAD, "LDSType"], [THEAD, "LDSType"],
[DHEAD, "LDSDate"], [DHEAD, "LDSDate"],
[TEMPLE, "LDSTemple"], [TEMPLE, "LDSTemple"],
[PHEAD, "LDSPlace"], [PHEAD, "LDSPlace"],
[ST, "LDSStatus"], [ST, "LDSStatus"],
[_("Sealed to "), "LDSSealed"], [SHEAD, "LDSSources"] ]
[SHEAD, "LDSSources"] )
]
# finish the label's missing piece
header_row[5][0] += PARENTS if LDSSealedType == "Person" else _("Spouse")
trow.extend(
Html("th", label, class_ = "Column" + colclass, inline = True)
for (label, colclass) in header_row)
# start table body # start table body
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
for row in range(1, (numberofords + 1)): for ord in objectldsord:
place_hyper = " "
# get ordinance for this row place_handle = ord.get_place_handle()
ord = objectldsord[(row - 1)] if place_handle:
place = db.get_place_from_handle(place_handle)
# 0 = column class, 1 = ordinance data if place:
lds_ord_data = [ place_hyper = self.place_link(place_handle, place.get_title(),
["LDSType", ord.type2xml()], place.gramps_id, True)
["LDSDate", _dd.display(ord.get_date_object() )],
["LDSTemple", ord.get_temple()],
["LDSPlace", ReportUtils.place_name(db, ord.get_place_handle() )],
["LDSStatus", ord.get_status()],
["LDSSealed", ord.get_family_handle()],
["LDSSources", self.get_citation_links(ord.get_source_references() )],
]
# begin ordinance rows # begin ordinance rows
trow = Html("tr") trow = Html("tr")
@ -763,7 +749,14 @@ class BasePage(object):
trow.extend( trow.extend(
Html("td", value or " ", class_ = "Column" + colclass, Html("td", value or " ", class_ = "Column" + colclass,
inline = (not value or colclass == "LDSDate")) inline = (not value or colclass == "LDSDate"))
for (colclass, value) in lds_ord_data) for (colclass, value) in [
["LDSType", ord.type2xml() ],
["LDSDate", _dd.display(ord.get_date_object() )],
["LDSTemple", ord.get_temple()],
["LDSPlace", place_hyper],
["LDSStatus", ord.get_status()],
["LDSSources", self.get_citation_links(ord.get_source_references() )] ]
)
# return table to its callers # return table to its callers
return table return table
@ -1880,44 +1873,45 @@ class BasePage(object):
# return hyperlink to its callers # return hyperlink to its callers
return hyper return hyper
def dump_place_locations(self, location, place = None): def dump_place_locations(self, location, tbody, place = None, alt_loc = False):
""" """
dump either main or alternate locations dump either main or alternate locations
@param: location -- either main or alternate location @param: location -- either main or alternate location
@param: trow -- table row elements @param: tbody -- table body element
@place -- either None or a place object @place -- either None or a place object to get latitude/ longitude
@param: alt_loc -- is this an alternate location?
""" """
if not location or not location.is_empty():
return
# begin table row # begin table row
trow = Html("tr") for (label, data) in [
# begin table row
place_location_fields = [
(STREET, location.street), (STREET, location.street),
(CITY, location.city), (CITY, location.city),
(PARISH, location.parish), (PARISH, location.parish),
(COUNTY, location.county), (COUNTY, location.county),
(STATE, location.state), (STATE, location.state),
(POSTAL, location.postal), (POSTAL, location.postal),
(COUNTRY, location.country) ] (COUNTRY, location.country) ]:
if data:
trow = Html("tr") + (
Html("td", label, class_ = "ColumnAttribute", inline = True),
Html("td", data, class_ = "ColumnValue")
)
tbody += trow
if place: if place:
place_location_fields += [ for (label, data) in [
(LATITUDE, place.lat), (LATITUDE, place.lat),
(LONGITUDE, place.long) ] (LONGITUDE, place.long) ]:
if data:
trow.extend( trow = Html("tr") + (
(Html("td", label, class_ = "ColumnAttribute", inline = True) + Html("td", label, class_ = "ColumnAttribute", inline = True),
Html("td", data, class_ = "ColumnValue") ) Html("td", data, class_ = "ColumnValue")
for (label, data) in place_location_fields
if data
) )
tbody += trow
# return table row back to its callers # return table body back to its callers
return trow return tbody
def dump_place(self, place, table): def dump_place(self, place, table):
""" """
@ -1926,9 +1920,6 @@ class BasePage(object):
@param: place -- place object from the database @param: place -- place object from the database
@param: table -- table from Placedetail @param: table -- table from Placedetail
""" """
if not place:
return
# add table body # add table body
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
@ -1943,16 +1934,15 @@ class BasePage(object):
if place.main_loc: if place.main_loc:
ml = place.get_main_location() ml = place.get_main_location()
tbody.extend( if ml and not ml.is_empty():
self.dump_place_locations(ml, place) self.dump_place_locations(ml, tbody, place)
)
# add alternate_locations if they exist # add alternate_locations
alt_loc = place.get_alternate_locations() al = place.get_alternate_locations()
for location in alt_loc: if al:
tbody.extend( for location in al:
self.dump_place_locations(location) if location and not location.is_empty():
) self.dump_place_locations(location, tbody, alt_loc = True)
# return place table to its callers # return place table to its callers
return table return table
@ -2452,9 +2442,9 @@ class PlacePage(BasePage):
return None return None
BasePage.__init__(self, report, title, place.gramps_id) BasePage.__init__(self, report, title, place.gramps_id)
of = self.report.create_file(place.get_handle(), "plc") of = self.report.create_file(place_handle, "plc")
self.up = True self.up = True
self.page_title = ReportUtils.place_name(db, place_handle) self.page_title = place.get_title()
placepage, head, body = self.write_header(_("Places")) placepage, head, body = self.write_header(_("Places"))
self.placemappages = self.report.options['placemappages'] self.placemappages = self.report.options['placemappages']