Sort events by date in the individual page.

Fixes #012717
This commit is contained in:
SNoiraud 2022-10-22 09:38:45 +02:00 committed by Nick Hall
parent 3dad2e8552
commit 974d4bae18
2 changed files with 12 additions and 1 deletions

View File

@ -218,6 +218,17 @@ class BasePage:
""" """
pass pass
def sort_by_event_date(self, handle):
""" Used to sort events by date. """
event = self.r_db.get_event_from_handle(handle.ref)
date = event.get_date_object()
if date.get_year() > 0:
return date
else:
# if we have no date, we'll put the event at the
# end of the list
return Date(9999, 1, 1)
def sort_on_name_and_grampsid(self, handle): def sort_on_name_and_grampsid(self, handle):
""" Used to sort on name and gramps ID. """ """ Used to sort on name and gramps ID. """
person = self.r_db.get_person_from_handle(handle) person = self.r_db.get_person_from_handle(handle)

View File

@ -1814,7 +1814,7 @@ class PersonPages(BasePage):
tbody = Html("tbody") tbody = Html("tbody")
table += tbody table += tbody
for evt_ref in event_ref_list: for evt_ref in sorted(event_ref_list, key=self.sort_by_event_date):
event = self.r_db.get_event_from_handle(evt_ref.ref) event = self.r_db.get_event_from_handle(evt_ref.ref)
if event: if event: