Narrative Web Feature requests : (#466)
Sort "Surname" web page by given name and birth date. Surname list doesn't use default name format Fixes #05315, #08067
This commit is contained in:
parent
d59fe6b2af
commit
43ef686622
@ -165,6 +165,18 @@ class BasePage: # pylint: disable=C1001
|
||||
name = _nd.display(person)
|
||||
return (name, person.get_gramps_id())
|
||||
|
||||
def sort_on_given_and_birth(self, handle):
|
||||
""" Used to sort on given name and birth date. """
|
||||
person = self.r_db.get_person_from_handle(handle)
|
||||
name = _nd.display_given(person)
|
||||
bd_event = get_birth_or_fallback(self.r_db, person)
|
||||
birth = ""
|
||||
if bd_event:
|
||||
birth_iso = str(bd_event.get_date_object()).replace('abt ', '')
|
||||
# we need to remove abt, bef, aft, ...
|
||||
birth = birth_iso.replace('aft ', '').replace('bef ', '')
|
||||
return (name, birth)
|
||||
|
||||
def sort_on_grampsid(self, event_ref):
|
||||
"""
|
||||
Sort on gramps ID
|
||||
|
@ -228,6 +228,8 @@ class PersonPages(BasePage):
|
||||
ppl_handle_list = sort_people(self.r_db, ppl_handle_list,
|
||||
self.rlocale)
|
||||
first = True
|
||||
name_format = self.report.options['name_format']
|
||||
nme_format = _nd.name_formats[name_format][1]
|
||||
for (surname, handle_list) in ppl_handle_list:
|
||||
|
||||
if surname and not surname.isspace():
|
||||
@ -237,6 +239,15 @@ class PersonPages(BasePage):
|
||||
letter = ' '
|
||||
surname = self._("<absent>")
|
||||
|
||||
# In case the user choose a format name like "*SURNAME*"
|
||||
# We must display this field in upper case. So we use the
|
||||
# english format of format_name to find if this is the case.
|
||||
# name_format = self.report.options['name_format']
|
||||
# nme_format = _nd.name_formats[name_format][1]
|
||||
if "SURNAME" in nme_format:
|
||||
surnamed = surname.upper()
|
||||
else:
|
||||
surnamed = surname
|
||||
first_surname = True
|
||||
for person_handle in sorted(handle_list,
|
||||
key=self.sort_on_name_and_grampsid):
|
||||
@ -261,12 +272,12 @@ class PersonPages(BasePage):
|
||||
{'surname' : surname,
|
||||
'letter' : letter})
|
||||
tcell += Html(
|
||||
"a", html_escape(surname), name=letter,
|
||||
"a", html_escape(surnamed), name=letter,
|
||||
id_=letter,
|
||||
title=ttle)
|
||||
elif first_surname:
|
||||
first_surname = False
|
||||
tcell += Html("a", html_escape(surname),
|
||||
tcell += Html("a", html_escape(surnamed),
|
||||
title=self._("Surnames") + " " + surname)
|
||||
else:
|
||||
tcell += " "
|
||||
|
@ -48,6 +48,7 @@ import logging
|
||||
# Gramps module
|
||||
#------------------------------------------------
|
||||
from gramps.gen.const import GRAMPS_LOCALE as glocale
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.gen.plug.report import utils
|
||||
from gramps.plugins.lib.libhtml import Html
|
||||
|
||||
@ -103,7 +104,17 @@ class SurnamePage(BasePage):
|
||||
body += surnamedetail
|
||||
|
||||
# section title
|
||||
surnamedetail += Html("h3", html_escape(surname), inline=True)
|
||||
# In case the user choose a format name like "*SURNAME*"
|
||||
# We must display this field in upper case. So we use
|
||||
# the english format of format_name to find if this is
|
||||
# the case.
|
||||
name_format = self.report.options['name_format']
|
||||
nme_format = _nd.name_formats[name_format][1]
|
||||
if "SURNAME" in nme_format:
|
||||
surnamed = surname.upper()
|
||||
else:
|
||||
surnamed = surname
|
||||
surnamedetail += Html("h3", html_escape(surnamed), inline=True)
|
||||
|
||||
# feature request 2356: avoid genitive form
|
||||
msg = self._("This page contains an index of all the individuals "
|
||||
@ -149,7 +160,7 @@ class SurnamePage(BasePage):
|
||||
table += tbody
|
||||
|
||||
for person_handle in sorted(ppl_handle_list,
|
||||
key=self.sort_on_name_and_grampsid):
|
||||
key=self.sort_on_given_and_birth):
|
||||
|
||||
person = self.r_db.get_person_from_handle(person_handle)
|
||||
if person.get_change_time() > ldatec:
|
||||
|
@ -54,6 +54,7 @@ from gramps.plugins.lib.libhtml import Html
|
||||
# specific narrative web import
|
||||
#------------------------------------------------
|
||||
from gramps.plugins.webreport.basepage import BasePage
|
||||
from gramps.gen.display.name import displayer as _nd
|
||||
from gramps.plugins.webreport.common import (get_first_letters, _KEYPERSON,
|
||||
alphabet_navigation, html_escape,
|
||||
sort_people, name_to_md5,
|
||||
@ -155,6 +156,7 @@ class SurnameListPage(BasePage):
|
||||
hyper = Html("a", num_people, href=fname, title=num_people)
|
||||
tcell += hyper
|
||||
|
||||
name_format = self.report.options['name_format']
|
||||
# begin table body
|
||||
with Html("tbody") as tbody:
|
||||
table += tbody
|
||||
@ -210,10 +212,19 @@ class SurnameListPage(BasePage):
|
||||
tcell += " "
|
||||
prev_surname = surname
|
||||
|
||||
# In case the user choose a format name like "*SURNAME*"
|
||||
# We must display this field in upper case. So we use
|
||||
# the english format of format_name to find if this is
|
||||
# the case.
|
||||
# name_format = self.report.options['name_format']
|
||||
nme_format = _nd.name_formats[name_format][1]
|
||||
if "SURNAME" in nme_format:
|
||||
surnamed = surname.upper()
|
||||
else:
|
||||
surnamed = surname
|
||||
trow += Html("td",
|
||||
self.surname_link(name_to_md5(surname),
|
||||
#html_escape(surname)),
|
||||
surname),
|
||||
surnamed),
|
||||
class_="ColumnSurname", inline=True)
|
||||
|
||||
trow += Html("td", len(data_list),
|
||||
|
Loading…
x
Reference in New Issue
Block a user