diff --git a/gramps/plugins/webreport/basepage.py b/gramps/plugins/webreport/basepage.py index 6c66df70a..67cce5d1a 100644 --- a/gramps/plugins/webreport/basepage.py +++ b/gramps/plugins/webreport/basepage.py @@ -218,6 +218,17 @@ class BasePage: """ 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) diff --git a/gramps/plugins/webreport/person.py b/gramps/plugins/webreport/person.py index 44dce57bc..076ae7214 100644 --- a/gramps/plugins/webreport/person.py +++ b/gramps/plugins/webreport/person.py @@ -1814,7 +1814,7 @@ class PersonPages(BasePage): 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: