Narrative web features: 5592 + 5408 + 10031 (#389)

* Feature: 5592 show more details + 5408 children dates

* NarrativeWeb: another translation problem.

* Narrativeweb: different locales.

* Feature 10031: maps not displaying all events
This commit is contained in:
Serge Noiraud 2017-05-13 08:07:32 +02:00 committed by GitHub
parent 2a2a0d2766
commit 5791788f0e

View File

@ -126,6 +126,7 @@ from gramps.gen.display.place import displayer as _pd
from gramps.gen.proxy import CacheProxyDb
from gramps.plugins.lib.libhtmlconst import _CHARACTER_SETS, _CC, _COPY_OPTIONS
from gramps.gen.datehandler import get_date
from gramps.gen.utils.db import get_birth_or_fallback, get_death_or_fallback
# import HTML Class from src/plugins/lib/libhtml.py
from gramps.plugins.lib.libhtml import Html, xml_lang
@ -764,11 +765,28 @@ class BasePage:
)
table = table + trow if table is not None else trow
tcell = Html("td", class_="ColumnValue")
tcell = Html("td", class_="ColumnValue", close=False)
trow += tcell
ordered = Html("ol")
tcell += ordered
with Html("table", class_="infolist eventlist") as table2:
thead = Html("thead")
table2 += thead
header = Html("tr")
header.extend(
Html("th", label, class_=colclass, inline=True)
for (label, colclass) in [
[self._("Name"), "ColumnName"],
[self._("Birth Date"), "ColumnDate"],
[self._("Death Date"), "ColumnDate"],
]
)
thead += header
# begin table body
tbody = Html("tbody")
table2 += tbody
childlist = [child_ref.ref for child_ref in childlist]
# add individual's children event places to family map...
@ -778,14 +796,21 @@ class BasePage:
if child:
self._get_event_place(child, place_lat_long)
children = add_birthdate(self.r_db, childlist)
children = add_birthdate(self.r_db, childlist, self.rlocale)
if birthorder:
children = sorted(children)
ordered.extend(
(Html("li") + self.display_child_link(chandle))
for birth_date, chandle in children
tbody.extend(
(
Html("tr", inline=True) +
Html("td", inline=True, close=False) +
self.display_child_link(chandle) +
Html("td", birth, inline=True) +
Html("td", death, inline=True)
)
for birth_date, birth, death, chandle in children
)
trow += table2
# family LDS ordinance list
family_lds_ordinance_list = family.get_lds_ord_list()
@ -819,6 +844,23 @@ class BasePage:
self.display_attr_list(family_attribute_list, attrtable)
return table
def display_dates(self, handle):
"""
used to display the birth date
@param: handle -- handle to the person
"""
birth = death = ""
person = self.r_db.get_person_from_handle(handle)
if person:
bd_event = get_birth_or_fallback(self.r_db, child)
if bd_event:
birth = self.rlocale.get_date(bd_event.get_date_object())
dd_event = get_death_or_fallback(self.r_db, child)
if dd_event:
death = self.rlocale.get_date(dd_event.get_date_object())
return birth, death
def complete_people(self, tcell, first_person, handle_list, uplink=True):
"""
completes the person column for classes EventListPage and EventPage
@ -982,7 +1024,7 @@ class BasePage:
for notehandle in notelist:
this_note = self.r_db.get_note_from_handle(notehandle)
if this_note is not None:
notesection.extend(Html("i", str(this_note.type),
notesection.extend(Html("i", self._(this_note.type.xml_str()),
class_="NoteType"))
notesection.extend(self.get_note_format(this_note, True))
return notesection
@ -1105,12 +1147,6 @@ class BasePage:
latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8")
if latitude is not None:
etype = event.get_type()
# only allow Birth, Death, Census, Marriage,
# and Divorce events...
if etype in [EventType.BIRTH, EventType.DEATH,
EventType.CENSUS,
EventType.MARRIAGE, EventType.DIVORCE]:
place_lat_long.append([latitude, longitude, placetitle,
place_handle, event_date, etype])
@ -2757,6 +2793,18 @@ class BasePage:
tcell += self.new_person_link(partner.get_handle(), uplink=True,
person=partner)
birth = death = ""
bd_event = get_birth_or_fallback(self.r_db, partner)
if bd_event:
birth = self.rlocale.get_date(bd_event.get_date_object())
dd_event = get_death_or_fallback(self.r_db, partner)
if dd_event:
death = self.rlocale.get_date(dd_event.get_date_object())
if death == "":
death = "..."
tcell += " ( * ", birth, " + ", death, " )"
return trow
def display_child_link(self, chandle):
@ -6209,7 +6257,7 @@ class PersonPages(BasePage):
elif first_surname:
first_surname = False
tcell += Html("a", html_escape(surname),
title="Surnames " + surname)
title=self._("Surnames") + " " + surname)
else:
tcell += " "
@ -6920,12 +6968,22 @@ class PersonPages(BasePage):
if win():
thumbnail_url = thumbnail_url.replace('\\', "/")
url = self.report.build_url_fname_html(person.handle, "ppl", True)
birth = death = ""
bd_event = get_birth_or_fallback(self.r_db, person)
if bd_event:
birth = self.rlocale.get_date(bd_event.get_date_object())
dd_event = get_death_or_fallback(self.r_db, person)
if dd_event:
death = self.rlocale.get_date(dd_event.get_date_object())
if death == "":
death = "..."
value = person_name + "<br/>*", birth, "<br/>+", death
if thumbnail_url is None:
boxbg += Html("a", href=url, class_="noThumb") + person_name
boxbg += Html("a", href=url, class_="noThumb") + value
else:
thumb = Html("span", class_="thumbnail") + (
Html("img", src=thumbnail_url, alt="Image: " + person_name))
boxbg += Html("a", href=url) + thumb + person_name
boxbg += Html("a", href=url) + thumb + value
shadow = Html(
"div", class_="shadow", inline=True,
style="top: %dpx; left: %dpx;" % (top + _SHADOW, xoff + _SHADOW))
@ -7144,12 +7202,12 @@ class PersonPages(BasePage):
childlist = family.get_child_ref_list()
childlist = [child_ref.ref for child_ref in childlist]
children = add_birthdate(self.r_db, childlist)
children = add_birthdate(self.r_db, childlist, self.rlocale)
if birthorder:
children = sorted(children)
for birthdate, handle in children:
for birthdate, birth, death, handle in children:
if handle == self.person.get_handle():
child_ped(ol_html)
elif handle:
@ -7411,13 +7469,32 @@ class PersonPages(BasePage):
@param: rel -- The relation
"""
tcell1 = Html("td", title, class_="ColumnAttribute", inline=True)
tcell2 = Html("td", class_="ColumnValue")
tcell2 = Html("td", class_="ColumnValue", close=False, inline=True)
tcell2 += self.new_person_link(handle, uplink=True)
if rel and rel != ChildRefType(ChildRefType.BIRTH):
tcell2 += ''.join(['&nbsp;'] *3 + ['(%s)']) % str(rel)
person = self.r_db.get_person_from_handle(handle)
birth = death = ""
if person:
bd_event = get_birth_or_fallback(self.r_db, person)
if bd_event:
birth = self.rlocale.get_date(bd_event.get_date_object())
dd_event = get_death_or_fallback(self.r_db, person)
if dd_event:
death = self.rlocale.get_date(dd_event.get_date_object())
tcell3 = Html("td", birth, class_="ColumnDate",
inline=False, close=False, indent=False)
tcell4 = Html("td", death, class_="ColumnDate",
inline=True, close=False, indent=False)
tcell2 += tcell3
tcell2 += tcell4
# return table columns to its caller
return tcell1, tcell2
@ -7504,7 +7581,8 @@ class PersonPages(BasePage):
except:
reln = self._("Not siblings")
reln = "&nbsp;&nbsp;&nbsp;&nbsp;" + reln
val1 = "&nbsp;&nbsp;&nbsp;&nbsp;"
reln = val1 + reln
# Now output reln, child_link, (frel, mrel)
frel = child_ref.get_father_relation()
mrel = child_ref.get_mother_relation()
@ -7515,10 +7593,27 @@ class PersonPages(BasePage):
trow = Html("tr") + (
Html("td", reln, class_="ColumnAttribute", inline=True))
tcell = Html("td", class_="ColumnValue", inline=True)
tcell += "&nbsp;&nbsp;&nbsp;&nbsp;"
tcell = Html("td", val1, class_="ColumnValue", inline=True)
tcell += self.display_child_link(child_handle)
birth = death = ""
bd_event = get_birth_or_fallback(self.r_db, child)
if bd_event:
birth = self.rlocale.get_date(bd_event.get_date_object())
dd_event = get_death_or_fallback(self.r_db, child)
if dd_event:
death = self.rlocale.get_date(dd_event.get_date_object())
tcell2 = Html("td", birth, class_="ColumnDate",
inline=True)
tcell3 = Html("td", death, class_="ColumnDate",
inline=True)
trow += tcell
trow += tcell2
trow += tcell3
tcell = Html("td", frelmrel, class_="ColumnValue",
inline=True)
trow += tcell
@ -7603,6 +7698,8 @@ class PersonPages(BasePage):
for (label, colclass) in [
(self._("Relation to main person"), "ColumnAttribute"),
(self._("Name"), "ColumnValue"),
(self._("Birth date"), "ColumnValue"),
(self._("Death date"), "ColumnValue"),
(self._("Relation within this family "
"(if not by birth)"),
"ColumnValue")
@ -7610,7 +7707,6 @@ class PersonPages(BasePage):
)
tbody = Html("tbody")
table += tbody
all_family_handles = list(parent_list)
(birthmother, birthfather) = self.rel_class.get_birth_parents(
@ -7623,7 +7719,7 @@ class PersonPages(BasePage):
# Display this family
self.display_ind_parent_family(birthmother,
birthfather,
family, table, first)
family, tbody, first)
first = False
if self.report.options['showhalfsiblings']:
@ -7633,11 +7729,12 @@ class PersonPages(BasePage):
self.display_step_families(
family.get_father_handle(), family,
all_family_handles,
birthmother, birthfather, table)
birthmother, birthfather, tbody)
self.display_step_families(
family.get_mother_handle(), family,
all_family_handles,
birthmother, birthfather, table)
birthmother, birthfather, tbody)
table += tbody
return section
def pedigree_person(self, person):
@ -10601,12 +10698,18 @@ def _has_webpage_extension(url):
"""
return any(url.endswith(ext) for ext in _WEB_EXT)
def add_birthdate(dbase, ppl_handle_list):
def add_birthdate(dbase, ppl_handle_list, rlocale):
"""
This will sort a list of child handles in birth order
For each entry in the list, we'll have :
birth date
The transtated birth date for the configured locale
The transtated death date for the configured locale
The handle for the child
@param: dbase -- The database to use
@param: ppl_handle_list -- the handle for the people
@param: rlocale -- the locale for date translation
"""
sortable_individuals = []
for person_handle in ppl_handle_list:
@ -10614,11 +10717,18 @@ def add_birthdate(dbase, ppl_handle_list):
person = dbase.get_person_from_handle(person_handle)
if person:
birth_ref = person.get_birth_ref()
birth1 = ""
if birth_ref:
birth = dbase.get_event_from_handle(birth_ref.ref)
if birth:
birth1 = rlocale.get_date(birth.get_date_object())
birth_date = birth.get_date_object().get_sort_value()
sortable_individuals.append((birth_date, person_handle))
death_event = get_death_or_fallback(dbase, person)
if death_event:
death = rlocale.get_date(death_event.get_date_object())
else:
death = ""
sortable_individuals.append((birth_date, birth1, death, person_handle))
# return a list of handles with the individual's birthdate attached
return sortable_individuals