Skip to content

Commit

Permalink
Add a name parameter to the get_person_mark utility
Browse files Browse the repository at this point in the history
This allows an alphabetical index entry for a person to use the
selected name format.  Previously a "Surname, Given Suffix"
format was always used.

Fixes #13155.
  • Loading branch information
Nick-Hall committed Jan 26, 2024
1 parent af47b1f commit 99041bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
5 changes: 3 additions & 2 deletions gramps/gen/plug/report/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def find_marriage(database, family):
# Indexing function
#
# -------------------------------------------------------------------------
def get_person_mark(dbase, person):
def get_person_mark(dbase, person, name=None):
"""
Return a IndexMark that can be used to index a person in a report
Expand All @@ -228,7 +228,8 @@ def get_person_mark(dbase, person):
if not person:
return None

name = person.get_primary_name().get_name()
if name is None:
name = person.get_primary_name().get_name()
birth = " "
death = " "
key = ""
Expand Down
11 changes: 6 additions & 5 deletions gramps/plugins/textreport/detancestralreport.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ def write_more_header(first, name):
name = self._nd.display(person)
if not name:
name = self._("Unknown")
mark = utils.get_person_mark(self._db, person)
mark = utils.get_person_mark(self._db, person, name)

self.doc.start_bold()
self.doc.write_text(name, mark)
Expand Down Expand Up @@ -559,14 +559,14 @@ def write_parents(self, person):
if mother_handle:
mother = self._db.get_person_from_handle(mother_handle)
mother_name = self._nd.display_name(mother.get_primary_name())
mother_mark = utils.get_person_mark(self._db, mother)
mother_mark = utils.get_person_mark(self._db, mother, mother_name)
else:
mother_name = ""
mother_mark = ""
if father_handle:
father = self._db.get_person_from_handle(father_handle)
father_name = self._nd.display_name(father.get_primary_name())
father_mark = utils.get_person_mark(self._db, father)
father_mark = utils.get_person_mark(self._db, father, father_name)
else:
father_name = ""
father_mark = ""
Expand All @@ -589,7 +589,8 @@ def write_marriage(self, person):
spouse_handle = utils.find_spouse(person, family)
if spouse_handle:
spouse = self._db.get_person_from_handle(spouse_handle)
spouse_mark = utils.get_person_mark(self._db, spouse)
spouse_name = self._nd.display_name(spouse.get_primary_name())
spouse_mark = utils.get_person_mark(self._db, spouse, spouse_name)
else:
spouse_mark = None

Expand Down Expand Up @@ -642,7 +643,7 @@ def write_children(self, family):
child_name = self._nd.display(child)
if not child_name:
child_name = self._("Unknown")
child_mark = utils.get_person_mark(self._db, child)
child_mark = utils.get_person_mark(self._db, child, child_name)

if self.childref and self.prev_gen_handles.get(child_handle):
value = int(self.prev_gen_handles.get(child_handle))
Expand Down

0 comments on commit 99041bc

Please sign in to comment.