NarrativeWeb: add enclosed by and encloses (place)

Fixes #10743

includes the problem with private places (see PR 679)
This commit is contained in:
SNoiraud 2018-10-15 11:52:46 +02:00 committed by Nick Hall
parent 2e17c65a2c
commit 979a477773

View File

@ -59,7 +59,7 @@ import logging
from gramps.gen.const import GRAMPS_LOCALE as glocale
from gramps.gen.lib import (FamilyRelType, NoteType, NameType, Person,
UrlType, Date, Name, PlaceType, EventRoleType,
Family, Citation)
Family, Citation, Place)
from gramps.gen.lib.date import Today
from gramps.gen.const import PROGRAM_NAME, URL_HOMEPAGE
from gramps.version import VERSION
@ -2634,6 +2634,93 @@ class BasePage: # pylint: disable=C1001
tbody += trow
tbody += Html("tr") + Html("td", " ", colspan=2)
# encloses
with Html("div", class_='subsection encloses') as encloses:
tbody += encloses
encloses += Html("h4", self._("Place Encloses"), inline=True)
with Html("table", class_="infolist place") as table:
encloses += table
visited = [place.handle]
for link in self.r_db.find_backlink_handles(
place.handle, include_classes=['Place']):
if link[1] in visited:
continue
visited.append(link[1])
c_place = self.r_db.get_place_from_handle(link[1])
placeref = None
for placeref in c_place.get_placeref_list():
if placeref.ref == place.handle:
eplace = self.r_db.get_place_from_handle(placeref.ref)
if not eplace:
continue
table += Html("tr") + Html("td",
c_place.get_name().get_value())
# enclosed by
with Html("div", class_='subsection encloses') as encloses:
tbody += encloses
encloses += Html("h4", self._("Enclosed By"), inline=True)
with Html("table", class_="infolist place") as table:
encloses += table
visited = [place.handle]
placeref = None
for placeref in place.get_placeref_list():
if placeref.ref in visited:
continue
visited.append(placeref.ref)
pplace = self.r_db.get_place_from_handle(placeref.ref)
if not pplace:
continue
table += Html("tr") + Html("td",
pplace.get_name().get_value())
# enclosed by
tbody += Html("tr") + Html("td", " ")
trow = Html("tr") + (
Html("th", self._("Enclosed By"),
class_="ColumnAttribute", inline=True),
)
tbody += trow
for placeref in place.get_placeref_list():
parent_place = self.r_db.get_place_from_handle(placeref.ref)
if parent_place:
place_name = parent_place.get_name().get_value()
if parent_place.handle in self.report.obj_dict[Place]:
place_hyper = self.place_link(parent_place.handle,
place_name,
uplink=self.uplink)
else:
place_hyper = place_name
trow = Html("tr") + (
Html("td", place_hyper, class_="ColumnValue",
inline=True))
tbody += trow
# enclose
tbody += Html("tr") + Html("td", " ")
trow = Html("tr") + (
Html("th", self._("Place Encloses"),
class_="ColumnAttribute", inline=True),
)
tbody += trow
for link in self.r_db.find_backlink_handles(
place.handle, include_classes=['Place']):
child_place = self.r_db.get_place_from_handle(link[1])
placeref = None
for placeref in child_place.get_placeref_list():
if placeref.ref == place.handle:
place_name = child_place.get_name().get_value()
if child_place.handle in self.report.obj_dict[Place]:
place_hyper = self.place_link(child_place.handle,
place_name,
uplink=self.uplink)
else:
place_hyper = place_name
trow = Html("tr") + (
Html("td", place_hyper,
class_="ColumnValue", inline=True))
tbody += trow
# return place table to its callers
return table