2007-07-27 09:21:54 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2000-2007 Donald N. Allingham
|
2008-05-19 00:54:28 +05:30
|
|
|
# Copyright (C) 2007-2008 Brian G. Matherly
|
2007-07-27 09:21:54 +05:30
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
#
|
2009-02-16 12:26:49 +05:30
|
|
|
#
|
|
|
|
# $Id$
|
|
|
|
#
|
|
|
|
#
|
2007-07-27 09:37:38 +05:30
|
|
|
"""
|
|
|
|
Display a person's events, both personal and family
|
|
|
|
"""
|
|
|
|
|
2007-12-21 11:52:46 +05:30
|
|
|
from Simple import SimpleAccess, by_date, SimpleDoc, SimpleTable
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2007-05-07 09:09:46 +05:30
|
|
|
|
|
|
|
def run(database, document, person):
|
2007-07-27 09:37:38 +05:30
|
|
|
"""
|
|
|
|
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
|
|
|
|
"""
|
2007-05-07 09:09:46 +05:30
|
|
|
|
2007-07-27 09:37:38 +05:30
|
|
|
sdb = SimpleAccess(database)
|
|
|
|
sdoc = SimpleDoc(document)
|
2008-04-18 06:39:32 +05:30
|
|
|
stab = SimpleTable(sdb)
|
2007-05-07 09:09:46 +05:30
|
|
|
|
|
|
|
# get the personal events
|
2007-07-27 09:37:38 +05:30
|
|
|
event_list = sdb.events(person)
|
2007-05-07 09:09:46 +05:30
|
|
|
|
|
|
|
# get the events of each family in which the person is
|
|
|
|
# a parent
|
2007-07-27 09:37:38 +05:30
|
|
|
for family in sdb.parent_in(person):
|
|
|
|
event_list += sdb.events(family)
|
2007-05-07 09:09:46 +05:30
|
|
|
|
|
|
|
# Sort the events by their date
|
|
|
|
event_list.sort(by_date)
|
|
|
|
|
|
|
|
# display the results
|
|
|
|
|
2007-07-27 09:37:38 +05:30
|
|
|
sdoc.title(_("Sorted events of %s") % sdb.name(person))
|
|
|
|
sdoc.paragraph("")
|
2007-05-07 09:09:46 +05:30
|
|
|
|
2007-12-21 11:52:46 +05:30
|
|
|
stab.columns(_("Event Type"), _("Event Date"), _("Event Place"))
|
2007-07-27 09:21:54 +05:30
|
|
|
|
2007-05-07 09:09:46 +05:30
|
|
|
for event in event_list:
|
2007-12-21 11:52:46 +05:30
|
|
|
stab.row(event,
|
2008-03-30 18:08:32 +05:30
|
|
|
sdb.event_date_obj(event),
|
2007-12-21 11:52:46 +05:30
|
|
|
sdb.event_place(event))
|
2008-04-18 06:39:32 +05:30
|
|
|
stab.write(sdoc)
|
2007-08-30 01:07:58 +05:30
|
|
|
|
2007-08-31 01:19:04 +05:30
|
|
|
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)
|
2008-04-18 06:39:32 +05:30
|
|
|
stab = SimpleTable(sdb)
|
2007-08-31 01:19:04 +05:30
|
|
|
|
|
|
|
# get the family events
|
|
|
|
event_list = [(_('Family'), x) for x in sdb.events(family)]
|
|
|
|
|
|
|
|
# get the events of father and mother
|
2007-12-21 11:52:46 +05:30
|
|
|
#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))]
|
2007-08-31 01:19:04 +05:30
|
|
|
|
|
|
|
# children events
|
|
|
|
event_list_children = []
|
|
|
|
for child in sdb.children(family) :
|
2007-12-21 11:52:46 +05:30
|
|
|
#name = sdb.first_name(child)
|
|
|
|
event_list_children += [(child, x) for x in sdb.events(child)]
|
2007-08-31 01:19:04 +05:30
|
|
|
|
|
|
|
# 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 %s - %s") %
|
|
|
|
(sdb.name(sdb.father(family)),
|
|
|
|
sdb.name(sdb.mother(family))))
|
|
|
|
sdoc.paragraph("")
|
|
|
|
|
2007-12-21 11:52:46 +05:30
|
|
|
stab.columns(_("Family Member"), _("Event Type"),
|
|
|
|
_("Event Date"), _("Event Place"))
|
2007-08-31 01:19:04 +05:30
|
|
|
|
2007-12-21 11:52:46 +05:30
|
|
|
for (person, event) in event_list:
|
|
|
|
stab.row(person, sdb.event_type(event),
|
2008-03-30 18:08:32 +05:30
|
|
|
sdb.event_date_obj(event),
|
2007-12-21 11:52:46 +05:30
|
|
|
sdb.event_place(event))
|
2008-04-18 06:39:32 +05:30
|
|
|
stab.write(sdoc)
|
2007-12-21 11:52:46 +05:30
|
|
|
|
2008-04-18 06:39:32 +05:30
|
|
|
stab = SimpleTable(sdb)
|
2007-08-31 01:19:04 +05:30
|
|
|
sdoc.header1(_("Personal events of the children"))
|
2007-12-21 11:52:46 +05:30
|
|
|
stab.columns(_("Family Member"), _("Event Type"),
|
|
|
|
_("Event Date"), _("Event Place"))
|
|
|
|
for (person, event) in event_list_children:
|
|
|
|
stab.row(person, sdb.event_type(event),
|
2008-03-30 18:08:32 +05:30
|
|
|
sdb.event_date_obj(event),
|
2007-12-21 11:52:46 +05:30
|
|
|
sdb.event_place(event))
|
2008-04-18 06:39:32 +05:30
|
|
|
stab.write(sdoc)
|
2009-10-24 19:23:20 +05:30
|
|
|
|
2007-08-31 01:19:04 +05:30
|
|
|
def fam_sort(event1, event2):
|
|
|
|
"""
|
|
|
|
Sort function that will compare two events by their dates.
|
|
|
|
|
|
|
|
@param event1: first event
|
|
|
|
@type event1: L{Event}
|
|
|
|
@param event2: second event
|
|
|
|
@type event2: L{Event}
|
|
|
|
@return: Returns -1 if event1 < event2, 0 if they are equal, and
|
|
|
|
1 if they are the same.
|
|
|
|
@rtype: int
|
|
|
|
"""
|
|
|
|
return by_date(event1[1],event2[1])
|