From 101ccbc9180a83a34b8978dd800570cd062f982e Mon Sep 17 00:00:00 2001 From: Serge Noiraud Date: Fri, 16 Jul 2021 09:19:28 +0200 Subject: [PATCH] Navweb: add place name to birth and death dates (#1228) * Navweb: add place name to birth and death dates when we use the toggle section. * Possible problem with RTL languages --- gramps/plugins/webreport/person.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/gramps/plugins/webreport/person.py b/gramps/plugins/webreport/person.py index 61bed2165..51b18f1a6 100644 --- a/gramps/plugins/webreport/person.py +++ b/gramps/plugins/webreport/person.py @@ -60,6 +60,7 @@ from gramps.gen.plug.report import utils from gramps.gen.utils.alive import probably_alive from gramps.gen.constfunc import win from gramps.gen.display.name import displayer as _nd +from gramps.gen.display.place import displayer as _pd from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback from gramps.plugins.lib.libhtml import Html from gramps.gen.utils.place import conv_lat_lon @@ -1683,10 +1684,19 @@ class PersonPages(BasePage): # Age At Death??? birth_date = Date.EMPTY birth_ref = self.person.get_birth_ref() + p_birth = "" if birth_ref: birth = self.r_db.get_event_from_handle(birth_ref.ref) if birth: birth_date = birth.get_date_object() + p_birth = _pd.display_event(self.r_db, birth) + + death_ref = self.person.get_death_ref() + p_death = "" + if death_ref: + death = self.r_db.get_event_from_handle(death_ref.ref) + if death: + p_death = _pd.display_event(self.r_db, death) death_date = _find_death_date(self.r_db, self.person) if birth_date and birth_date is not Date.EMPTY: @@ -1705,11 +1715,26 @@ class PersonPages(BasePage): table += trow if self.report.options['toggle']: # Show birth and/or death date if we use the close button. + # If we have associated places, show them. + if p_birth: + p_birth = "%(bdat)s (%(pbirth)s)" % { + 'bdat': self.rlocale.get_date(birth_date), + 'pbirth': p_birth + } + elif birth_ref and birth: + p_birth = self.rlocale.get_date(birth_date) + if p_death: + p_death = "%(ddat)s (%(pdeath)s)" % { + 'ddat': self.rlocale.get_date(death_date), + 'pdeath': p_death + } + elif death_ref and death: + p_death = self.rlocale.get_date(death_date) if birth_date and birth_date is not Date.EMPTY: trow = Html("tr") + ( Html("td", self._("Birth date"), class_="ColumnAttribute", inline=True), - Html("td", self.rlocale.get_date(birth_date), + Html("td", p_birth, class_="ColumnValue", inline=True) ) table += trow @@ -1717,7 +1742,7 @@ class PersonPages(BasePage): trow = Html("tr") + ( Html("td", self._("Death date"), class_="ColumnAttribute", inline=True), - Html("td", self.rlocale.get_date(death_date), + Html("td", p_death, class_="ColumnValue", inline=True) ) table += trow