Skip to content

Commit

Permalink
Sort events by date in the individual page.
Browse files Browse the repository at this point in the history
Fixes #012717
  • Loading branch information
SNoiraud authored and Nick-Hall committed Jul 24, 2023
1 parent 3dad2e8 commit 974d4ba
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions gramps/plugins/webreport/basepage.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,17 @@ def display_pages(self, the_lang, the_title):
"""
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):
""" Used to sort on name and gramps ID. """
person = self.r_db.get_person_from_handle(handle)
Expand Down
2 changes: 1 addition & 1 deletion gramps/plugins/webreport/person.py
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ def display_ind_events(self, place_lat_long):
tbody = Html("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)
if event:

Expand Down

0 comments on commit 974d4ba

Please sign in to comment.