def run_fam(database, document, family): """ Loops through the family events and the events of all parents, displaying the basic details of the event """ sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = SimpleTable(sdb) # get the family events event_list = [(_('Family'), x) for x in sdb.events(family)] # get the events of father and mother #fathername = sdb.first_name(sdb.father(family)) event_list += [(sdb.father(family), x) for x in sdb.events(sdb.father(family))] #mothername = sdb.first_name(sdb.mother(family)) event_list += [(sdb.mother(family), x) for x in sdb.events(sdb.mother(family))] # children events event_list_children = [] for child in sdb.children(family): #name = sdb.first_name(child) event_list_children += [(child, x) for x in sdb.events(child)] # Sort the events by their date event_list.sort(fam_sort) event_list_children.sort(fam_sort) # display the results sdoc.title( _("Sorted events of family\n %(father)s - %(mother)s") % { 'father': sdb.name(sdb.father(family)), 'mother': sdb.name(sdb.mother(family)) }) sdoc.paragraph("") document.has_data = False stab.columns(_("Family Member"), _("Event Type"), _("Event Date"), _("Event Place")) for (person, event) in event_list: stab.row(person, sdb.event_type(event), sdb.event_date_obj(event), sdb.event_place(event)) document.has_data = True stab.write(sdoc) stab = SimpleTable(sdb) sdoc.header1(_("Personal events of the children")) stab.columns(_("Family Member"), _("Event Type"), _("Event Date"), _("Event Place")) for (person, event) in event_list_children: stab.row(person, sdb.event_type(event), sdb.event_date_obj(event), sdb.event_place(event)) document.has_data = True stab.write(sdoc)
def run(database, document, person): """ Loops through the person events and the family events of any family in which the person is a parent (to catch Marriage events), displaying the basic details of the event """ sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = SimpleTable(sdb) # get the personal events event_list = sdb.events(person) # get the events of each family in which the person is # a parent for family in sdb.parent_in(person): event_list += sdb.events(family) # Sort the events by their date event_list.sort(by_date) # display the results # feature request 2356: avoid genitive form sdoc.title(_("Sorted events of %s") % sdb.name(person)) sdoc.paragraph("") stab.columns(_("Event Type"), _("Event Date"), _("Event Place")) document.has_data = False for event in event_list: stab.row(event, sdb.event_date_obj(event), sdb.event_place(event)) document.has_data = True stab.write(sdoc)
def run(database, document, main_event): """ Displays events on a specific date of an event (or date) Takes an Event or Date object """ if isinstance(main_event, gen.lib.Date): main_date = main_event else: main_date = main_event.get_date_object() cal = main_date.get_calendar() # setup the simple access functions sdb = SimpleAccess(database) sdoc = SimpleDoc(document) stab = SimpleTable(sdb) stab.set_link_col(3) yeartab = SimpleTable(sdb) yeartab.set_link_col(3) histab = SimpleTable(sdb) histab.set_link_col(3) # display the title sdoc.title(_("Events of %(date)s") % {"date": sdb.date_string(main_date)}) sdoc.paragraph("") stab.columns(_("Date"), _("Type"), _("Place"), _("Reference")) yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference")) histab.columns(_("Date"), _("Type"), _("Place"), _("Reference")) for event in database.iter_events(): date = event.get_date_object() date.convert_calendar(cal) if date.get_year() == 0: continue if (date.get_year() == main_date.get_year() and date.get_month() == main_date.get_month() and date.get_day() == main_date.get_day()): for (objclass, handle) in database.find_backlink_handles(event.handle): ref = get_ref(database, objclass, handle) stab.row(date, sdb.event_type(event), sdb.event_place(event), ref) elif (date.get_month() == main_date.get_month() and date.get_day() == main_date.get_day() and date.get_month() != 0): for (objclass, handle) in database.find_backlink_handles(event.handle): ref = get_ref(database, objclass, handle) histab.row(date, sdb.event_type(event), sdb.event_place(event), ref) elif (date.get_year() == main_date.get_year()): for (objclass, handle) in database.find_backlink_handles(event.handle): ref = get_ref(database, objclass, handle) yeartab.row(date, sdb.event_type(event), sdb.event_place(event), ref) document.has_data = False if stab.get_row_count() > 0: document.has_data = True sdoc.paragraph(_("Events on this exact date")) stab.write(sdoc) else: sdoc.paragraph(_("No events on this exact date")) sdoc.paragraph("") sdoc.paragraph("") if histab.get_row_count() > 0: document.has_data = True sdoc.paragraph(_("Other events on this month/day in history")) histab.write(sdoc) else: sdoc.paragraph(_("No other events on this month/day in history")) sdoc.paragraph("") sdoc.paragraph("") if yeartab.get_row_count() > 0: document.has_data = True sdoc.paragraph( _("Other events in %(year)d") % {"year": main_date.get_year()}) yeartab.write(sdoc) else: sdoc.paragraph( _("No other events in %(year)d") % {"year": main_date.get_year()}) sdoc.paragraph("") sdoc.paragraph("")