9016 : narrativeweb: Place title based on current date not that of the event
This commit is contained in:
parent
df90ef58fd
commit
e50f0c145e
@ -129,6 +129,7 @@ from gramps.gen.display.place import displayer as _pd
|
|||||||
from gramps.gen.datehandler import displayer as _dd
|
from gramps.gen.datehandler import displayer as _dd
|
||||||
from gramps.gen.proxy import LivingProxyDb
|
from gramps.gen.proxy import LivingProxyDb
|
||||||
from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
|
from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
|
||||||
|
from gramps.gen.datehandler import get_date
|
||||||
|
|
||||||
# import HTML Class from src/plugins/lib/libhtml.py
|
# import HTML Class from src/plugins/lib/libhtml.py
|
||||||
from gramps.plugins.lib.libhtml import Html, xml_lang
|
from gramps.plugins.lib.libhtml import Html, xml_lang
|
||||||
@ -141,7 +142,7 @@ from gramps.gen.utils.place import conv_lat_lon
|
|||||||
from gramps.gui.pluginmanager import GuiPluginManager
|
from gramps.gui.pluginmanager import GuiPluginManager
|
||||||
|
|
||||||
from gramps.gen.relationship import get_relationship_calculator
|
from gramps.gen.relationship import get_relationship_calculator
|
||||||
from gramps.gen.utils.location import get_main_location
|
from gramps.gen.utils.location import get_main_location, get_location_list
|
||||||
|
|
||||||
COLLATE_LANG = glocale.collation
|
COLLATE_LANG = glocale.collation
|
||||||
SORT_KEY = glocale.sort_key
|
SORT_KEY = glocale.sort_key
|
||||||
@ -391,6 +392,7 @@ THEAD = _("Type")
|
|||||||
TEMPLE = _("Temple")
|
TEMPLE = _("Temple")
|
||||||
VHEAD = _("Value")
|
VHEAD = _("Value")
|
||||||
ALT_LOCATIONS = _("Alternate Locations")
|
ALT_LOCATIONS = _("Alternate Locations")
|
||||||
|
LOCATIONS = _("Locations")
|
||||||
_UNKNOWN = _("Unknown")
|
_UNKNOWN = _("Unknown")
|
||||||
_ABSENT = _("<absent>")
|
_ABSENT = _("<absent>")
|
||||||
|
|
||||||
@ -502,7 +504,7 @@ def get_gendex_data(database, event_ref):
|
|||||||
if place_handle:
|
if place_handle:
|
||||||
place = database.get_place_from_handle(place_handle)
|
place = database.get_place_from_handle(place_handle)
|
||||||
if place:
|
if place:
|
||||||
poe = _pd.display(database, place)
|
poe = _pd.display(database, place, date)
|
||||||
return doe, poe
|
return doe, poe
|
||||||
|
|
||||||
def format_date(date):
|
def format_date(date):
|
||||||
@ -1208,7 +1210,7 @@ class BasePage(object):
|
|||||||
|
|
||||||
place_hyper = None
|
place_hyper = None
|
||||||
if place:
|
if place:
|
||||||
place_name = ReportUtils.place_name(self.dbase_, place_handle)
|
place_name = _pd.display(self.dbase_, place, evt.get_date_object())
|
||||||
place_hyper = self.place_link(place_handle, place_name, uplink = up)
|
place_hyper = self.place_link(place_handle, place_name, uplink = up)
|
||||||
|
|
||||||
evt_desc = evt.get_description()
|
evt_desc = evt.get_description()
|
||||||
@ -2033,7 +2035,7 @@ class BasePage(object):
|
|||||||
_linkurl = self.report.build_url_fname_html(_obj.handle, "evt", True)
|
_linkurl = self.report.build_url_fname_html(_obj.handle, "evt", True)
|
||||||
elif classname == "Place":
|
elif classname == "Place":
|
||||||
_obj = self.dbase_.get_place_from_handle(newhandle)
|
_obj = self.dbase_.get_place_from_handle(newhandle)
|
||||||
_name = ReportUtils.place_name(self.dbase_, newhandle)
|
_name = _pd.display(self.dbase_, _obj)
|
||||||
if not _name:
|
if not _name:
|
||||||
_name = _UNKNOWN
|
_name = _UNKNOWN
|
||||||
_linkurl = self.report.build_url_fname_html(newhandle, "plc", True)
|
_linkurl = self.report.build_url_fname_html(newhandle, "plc", True)
|
||||||
@ -2625,6 +2627,9 @@ 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 place in self.visited:
|
||||||
|
return
|
||||||
|
self.visited.append(place)
|
||||||
# add table body
|
# add table body
|
||||||
tbody = Html("tbody")
|
tbody = Html("tbody")
|
||||||
table += tbody
|
table += tbody
|
||||||
@ -2694,6 +2699,19 @@ class BasePage(object):
|
|||||||
tbody += trow
|
tbody += trow
|
||||||
tbody += Html("tr") + Html("td", " ", colspan = 2)
|
tbody += Html("tr") + Html("td", " ", colspan = 2)
|
||||||
|
|
||||||
|
# display all related locations
|
||||||
|
for placeref in place.get_placeref_list():
|
||||||
|
place_date = get_date(placeref)
|
||||||
|
if place_date != "":
|
||||||
|
parent_place = self.db.get_place_from_handle(placeref.ref)
|
||||||
|
parent_name = parent_place.get_name().get_value()
|
||||||
|
trow = Html('tr') + (
|
||||||
|
Html("td", LOCATIONS, class_ = "ColumnAttribute", inline =True),
|
||||||
|
Html("td", parent_name, class_ = "ColumnValue", inline = True),
|
||||||
|
Html("td", place_date, class_ = "ColumnValue", inline = True)
|
||||||
|
)
|
||||||
|
tbody += trow
|
||||||
|
|
||||||
# return place table to its callers
|
# return place table to its callers
|
||||||
return table
|
return table
|
||||||
|
|
||||||
@ -3321,6 +3339,7 @@ class PlacePages(BasePage):
|
|||||||
self.report = report
|
self.report = report
|
||||||
self.db = report.database
|
self.db = report.database
|
||||||
self.place_dict = defaultdict(set)
|
self.place_dict = defaultdict(set)
|
||||||
|
self.visited = []
|
||||||
|
|
||||||
def display_pages(self, title):
|
def display_pages(self, title):
|
||||||
"""
|
"""
|
||||||
@ -3392,18 +3411,22 @@ class PlacePages(BasePage):
|
|||||||
)
|
)
|
||||||
|
|
||||||
handle_list = sorted(place_handles,
|
handle_list = sorted(place_handles,
|
||||||
key=lambda x: SORT_KEY(ReportUtils.place_name(self.dbase_, x)))
|
key=lambda x: SORT_KEY(ReportUtils.place_name(self.dbase_,
|
||||||
|
x[:x.index(':')])))
|
||||||
first = True
|
first = True
|
||||||
|
|
||||||
# begin table body
|
# begin table body
|
||||||
tbody = Html("tbody")
|
tbody = Html("tbody")
|
||||||
table += tbody
|
table += tbody
|
||||||
|
|
||||||
for place_handle in handle_list:
|
for place_handle_key in handle_list:
|
||||||
|
event_date = self.report.obj_dict[Place][place_handle_key][4]
|
||||||
|
place_handle = self.report.obj_dict[Place][place_handle_key][0]
|
||||||
|
place_name = self.report.obj_dict[Place][place_handle_key][2]
|
||||||
place = self.dbase_.get_place_from_handle(place_handle)
|
place = self.dbase_.get_place_from_handle(place_handle)
|
||||||
if place:
|
if place:
|
||||||
if place.get_change_time() > ldatec: ldatec = place.get_change_time()
|
if place.get_change_time() > ldatec: ldatec = place.get_change_time()
|
||||||
place_title = _pd.display(self.dbase_, place)
|
place_title = _pd.display(self.dbase_, place, event_date)
|
||||||
ml = get_main_location(self.dbase_, place)
|
ml = get_main_location(self.dbase_, place)
|
||||||
|
|
||||||
if place_title and not place_title.isspace():
|
if place_title and not place_title.isspace():
|
||||||
@ -3461,9 +3484,14 @@ class PlacePages(BasePage):
|
|||||||
# and close the file
|
# and close the file
|
||||||
self.XHTMLWriter(placelistpage, of, sio, ldatec)
|
self.XHTMLWriter(placelistpage, of, sio, ldatec)
|
||||||
|
|
||||||
def PlacePage(self, report, title, place_handle):
|
def PlacePage(self, report, title, key):
|
||||||
self.bibli = Bibliography()
|
self.bibli = Bibliography()
|
||||||
self.dbase_ = report.database
|
self.dbase_ = report.database
|
||||||
|
place_handle = self.report.obj_dict[Place][key][0]
|
||||||
|
place_fname = self.report.obj_dict[Place][key][1]
|
||||||
|
place_name = self.report.obj_dict[Place][key][2]
|
||||||
|
place_id = self.report.obj_dict[Place][key][3]
|
||||||
|
event_date = self.report.obj_dict[Place][key][4]
|
||||||
place = self.dbase_.get_place_from_handle(place_handle)
|
place = self.dbase_.get_place_from_handle(place_handle)
|
||||||
if not place:
|
if not place:
|
||||||
return None
|
return None
|
||||||
@ -3472,7 +3500,7 @@ class PlacePages(BasePage):
|
|||||||
|
|
||||||
of, sio = self.report.create_file(place_handle, "plc")
|
of, sio = self.report.create_file(place_handle, "plc")
|
||||||
self.up = True
|
self.up = True
|
||||||
self.page_title = _pd.display(self.dbase_, place)
|
self.page_title = _pd.display(self.dbase_, place, event_date)
|
||||||
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']
|
||||||
@ -3489,7 +3517,7 @@ class PlacePages(BasePage):
|
|||||||
placedetail += thumbnail
|
placedetail += thumbnail
|
||||||
|
|
||||||
# add section title
|
# add section title
|
||||||
placedetail += Html("h3", html_escape(self.page_title), inline =True)
|
placedetail += Html("h3", html_escape(place.get_name().get_value()), inline =True)
|
||||||
|
|
||||||
# begin summaryarea division and places table
|
# begin summaryarea division and places table
|
||||||
with Html("div", id ='summaryarea') as summaryarea:
|
with Html("div", id ='summaryarea') as summaryarea:
|
||||||
@ -3521,7 +3549,7 @@ class PlacePages(BasePage):
|
|||||||
if self.placemappages:
|
if self.placemappages:
|
||||||
if (place and (place.lat and place.long)):
|
if (place and (place.lat and place.long)):
|
||||||
latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8")
|
latitude, longitude = conv_lat_lon(place.get_latitude(), place.get_longitude(), "D.D8")
|
||||||
placetitle = _pd.display(self.dbase_, place)
|
placetitle = place_name
|
||||||
|
|
||||||
# add narrative-maps CSS...
|
# add narrative-maps CSS...
|
||||||
fname = "/".join(["css", "narrative-maps.css"])
|
fname = "/".join(["css", "narrative-maps.css"])
|
||||||
@ -7259,7 +7287,7 @@ class NavWebReport(Report):
|
|||||||
self._add_event(evt_ref.ref, Person, person_handle)
|
self._add_event(evt_ref.ref, Person, person_handle)
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
self._add_place(place_handle, Person, person_handle)
|
self._add_place(place_handle, Person, person_handle, event.get_date_object())
|
||||||
# If event pages are not being output, then tell the
|
# If event pages are not being output, then tell the
|
||||||
# media tab to display the perosn's event media. If
|
# media tab to display the perosn's event media. If
|
||||||
# events are being displayed, then the media are linked
|
# events are being displayed, then the media are linked
|
||||||
@ -7291,7 +7319,7 @@ class NavWebReport(Report):
|
|||||||
self._add_event(evt_ref.ref, Person, person_handle)
|
self._add_event(evt_ref.ref, Person, person_handle)
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
self._add_place(place_handle, Person, person_handle)
|
self._add_place(place_handle, Person, person_handle, event.get_date_object())
|
||||||
for citation_handle in event.get_citation_list():
|
for citation_handle in event.get_citation_list():
|
||||||
self._add_citation(
|
self._add_citation(
|
||||||
citation_handle, Person, person_handle)
|
citation_handle, Person, person_handle)
|
||||||
@ -7339,7 +7367,6 @@ class NavWebReport(Report):
|
|||||||
media_handle = media_ref.get_reference_handle()
|
media_handle = media_ref.get_reference_handle()
|
||||||
self._add_media(media_handle, Person, person_handle)
|
self._add_media(media_handle, Person, person_handle)
|
||||||
|
|
||||||
|
|
||||||
def get_person_name(self, person):
|
def get_person_name(self, person):
|
||||||
"""
|
"""
|
||||||
Return a string containing the person's primary name in the name
|
Return a string containing the person's primary name in the name
|
||||||
@ -7376,7 +7403,7 @@ class NavWebReport(Report):
|
|||||||
event = self.database.get_event_from_handle(evt_ref.ref)
|
event = self.database.get_event_from_handle(evt_ref.ref)
|
||||||
place_handle = event.get_place_handle()
|
place_handle = event.get_place_handle()
|
||||||
if place_handle:
|
if place_handle:
|
||||||
self._add_place(place_handle, Family, family_handle)
|
self._add_place(place_handle, Family, family_handle, event.get_date_object())
|
||||||
|
|
||||||
if self.inc_events:
|
if self.inc_events:
|
||||||
# detail for family events are displayed on the events pages as
|
# detail for family events are displayed on the events pages as
|
||||||
@ -7471,16 +7498,16 @@ class NavWebReport(Report):
|
|||||||
media_handle = media_ref.get_reference_handle()
|
media_handle = media_ref.get_reference_handle()
|
||||||
self._add_media(media_handle, Event, event_handle)
|
self._add_media(media_handle, Event, event_handle)
|
||||||
|
|
||||||
def _add_place(self, place_handle, bkref_class, bkref_handle):
|
def _add_place(self, place_handle, bkref_class, bkref_handle, date):
|
||||||
place = self.database.get_place_from_handle(place_handle)
|
place = self.database.get_place_from_handle(place_handle)
|
||||||
if place is None:
|
if place is None:
|
||||||
return
|
return
|
||||||
place_name = _pd.display(self.database, place)
|
place_name = _pd.display(self.database, place, date)
|
||||||
place_fname = self.build_url_fname(place_handle, "plc",
|
place_fname = self.build_url_fname(place_handle, "plc",
|
||||||
False) + self.ext
|
False) + self.ext
|
||||||
self.obj_dict[Place][place_handle] = (place_fname, place_name,
|
self.obj_dict[Place][place_handle+":"+place_name] = (place_handle, place_fname, place_name,
|
||||||
place.gramps_id)
|
place.gramps_id, date)
|
||||||
self.bkref_dict[Place][place_handle].add((bkref_class, bkref_handle))
|
self.bkref_dict[Place][place_handle+place_name].add((bkref_class, bkref_handle))
|
||||||
|
|
||||||
############### Media section ##############
|
############### Media section ##############
|
||||||
if self.inc_gallery:
|
if self.inc_gallery:
|
||||||
@ -8779,7 +8806,8 @@ def get_first_letters(dbase, handle_list, key):
|
|||||||
keyname = __get_person_keyname(dbase, handle)
|
keyname = __get_person_keyname(dbase, handle)
|
||||||
|
|
||||||
elif key == _KEYPLACE:
|
elif key == _KEYPLACE:
|
||||||
keyname = __get_place_keyname(dbase, handle)
|
real_handle = handle[:handle.index(':')]
|
||||||
|
keyname = __get_place_keyname(dbase, real_handle)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
keyname = handle
|
keyname = handle
|
||||||
|
Loading…
x
Reference in New Issue
Block a user