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:
Serge Noiraud 2017-11-23 09:39:12 +01:00 committed by GitHub
parent d59fe6b2af
commit 43ef686622
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 6 deletions

View File

@ -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

View File

@ -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 = '&nbsp'
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 += "&nbsp;"

View File

@ -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:

View File

@ -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 += "&nbsp;"
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),