2007-12-30 01:25:27 +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-12-30 01:25:27 +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-12-30 01:25:27 +05:30
|
|
|
|
|
|
|
"""
|
|
|
|
Display all events on a particular day.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
|
|
|
from gettext import gettext as _
|
2007-12-30 21:09:00 +05:30
|
|
|
import gen.lib
|
2007-12-30 01:25:27 +05:30
|
|
|
|
2007-12-30 21:09:00 +05:30
|
|
|
def get_ref(db, objclass, handle):
|
|
|
|
"""
|
|
|
|
Looks up object in database
|
|
|
|
"""
|
2007-12-30 02:36:15 +05:30
|
|
|
if objclass == 'Person':
|
2007-12-30 21:09:00 +05:30
|
|
|
ref = db.get_person_from_handle(handle)
|
|
|
|
elif objclass == 'Family':
|
|
|
|
ref = db.get_family_from_handle(handle)
|
|
|
|
elif objclass == 'Event':
|
|
|
|
ref = db.get_event_from_handle(handle)
|
|
|
|
elif objclass == 'Source':
|
|
|
|
ref = db.get_source_from_handle(handle)
|
|
|
|
elif objclass == 'Place':
|
|
|
|
ref = db.get_place_from_handle(handle)
|
|
|
|
elif objclass == 'Repository':
|
|
|
|
ref = db.get_repository_from_handle(handle)
|
2007-12-30 02:36:15 +05:30
|
|
|
else:
|
|
|
|
ref = objclass
|
|
|
|
return ref
|
|
|
|
|
2007-12-30 01:25:27 +05:30
|
|
|
def run(database, document, main_event):
|
|
|
|
"""
|
2007-12-30 21:09:00 +05:30
|
|
|
Displays events on a specific date of an event (or date)
|
2007-12-30 09:16:39 +05:30
|
|
|
|
2007-12-30 21:09:00 +05:30
|
|
|
Takes an Event or Date object
|
2007-12-30 01:25:27 +05:30
|
|
|
"""
|
2007-12-30 21:09:00 +05:30
|
|
|
if isinstance(main_event, gen.lib.Date):
|
|
|
|
main_date = main_event
|
|
|
|
else:
|
|
|
|
main_date = main_event.get_date_object()
|
|
|
|
|
2007-12-30 01:25:27 +05:30
|
|
|
# setup the simple access functions
|
|
|
|
sdb = SimpleAccess(database)
|
|
|
|
sdoc = SimpleDoc(document)
|
2008-04-18 06:39:32 +05:30
|
|
|
stab = SimpleTable(sdb)
|
2008-01-16 07:55:40 +05:30
|
|
|
stab.set_link_col(3)
|
2008-04-18 06:39:32 +05:30
|
|
|
yeartab = SimpleTable(sdb)
|
2008-01-16 07:55:40 +05:30
|
|
|
yeartab.set_link_col(3)
|
2008-04-18 06:39:32 +05:30
|
|
|
histab = SimpleTable(sdb)
|
2008-01-16 07:55:40 +05:30
|
|
|
histab.set_link_col(3)
|
2007-12-30 01:25:27 +05:30
|
|
|
|
|
|
|
# display the title
|
2007-12-30 21:09:00 +05:30
|
|
|
sdoc.title(_("Events of %(date)s") %
|
|
|
|
{"date": sdb.date_string(main_date)})
|
2007-12-30 01:25:27 +05:30
|
|
|
sdoc.paragraph("")
|
2007-12-30 02:36:15 +05:30
|
|
|
stab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
|
|
|
|
yeartab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
|
|
|
|
histab.columns(_("Date"), _("Type"), _("Place"), _("Reference"))
|
2007-12-30 01:25:27 +05:30
|
|
|
|
2009-09-16 01:07:23 +05:30
|
|
|
for event in database.iter_events():
|
2007-12-30 01:25:27 +05:30
|
|
|
date = event.get_date_object()
|
|
|
|
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()):
|
2009-09-16 01:07:23 +05:30
|
|
|
for (objclass, handle) in database.find_backlink_handles(event.handle):
|
2007-12-30 21:09:00 +05:30
|
|
|
ref = get_ref(database, objclass, handle)
|
2007-12-30 02:36:15 +05:30
|
|
|
stab.row(date,
|
|
|
|
sdb.event_type(event),
|
|
|
|
sdb.event_place(event), ref)
|
2007-12-30 01:25:27 +05:30
|
|
|
elif (date.get_month() == main_date.get_month() and
|
2007-12-30 02:36:15 +05:30
|
|
|
date.get_day() == main_date.get_day() and
|
|
|
|
date.get_month() != 0):
|
2009-09-16 01:07:23 +05:30
|
|
|
for (objclass, handle) in database.find_backlink_handles(event.handle):
|
2007-12-30 21:09:00 +05:30
|
|
|
ref = get_ref(database, objclass, handle)
|
2007-12-30 02:36:15 +05:30
|
|
|
histab.row(date,
|
|
|
|
sdb.event_type(event),
|
|
|
|
sdb.event_place(event), ref)
|
2007-12-30 01:25:27 +05:30
|
|
|
elif (date.get_year() == main_date.get_year()):
|
2009-09-16 01:07:23 +05:30
|
|
|
for (objclass, handle) in database.find_backlink_handles(event.handle):
|
2007-12-30 21:09:00 +05:30
|
|
|
ref = get_ref(database, objclass, handle)
|
2007-12-30 02:36:15 +05:30
|
|
|
yeartab.row(date,
|
|
|
|
sdb.event_type(event),
|
|
|
|
sdb.event_place(event), ref)
|
2007-12-30 01:25:27 +05:30
|
|
|
|
2007-12-30 21:09:00 +05:30
|
|
|
if stab.get_row_count() > 0:
|
|
|
|
sdoc.paragraph(_("Events on this exact date"))
|
2008-04-18 06:39:32 +05:30
|
|
|
stab.write(sdoc)
|
2007-12-30 21:09:00 +05:30
|
|
|
else:
|
|
|
|
sdoc.paragraph(_("No events on this exact date"))
|
|
|
|
sdoc.paragraph("")
|
2007-12-30 01:25:27 +05:30
|
|
|
sdoc.paragraph("")
|
2007-12-30 21:09:00 +05:30
|
|
|
|
2007-12-30 01:25:27 +05:30
|
|
|
if histab.get_row_count() > 0:
|
2007-12-30 21:09:00 +05:30
|
|
|
sdoc.paragraph(_("Other events on this month/day in history"))
|
2008-04-18 06:39:32 +05:30
|
|
|
histab.write(sdoc)
|
2007-12-30 21:09:00 +05:30
|
|
|
else:
|
|
|
|
sdoc.paragraph(_("No other events on this month/day in history"))
|
|
|
|
sdoc.paragraph("")
|
2007-12-30 01:25:27 +05:30
|
|
|
sdoc.paragraph("")
|
2007-12-30 21:09:00 +05:30
|
|
|
|
2007-12-30 01:25:27 +05:30
|
|
|
if yeartab.get_row_count() > 0:
|
2007-12-30 21:09:00 +05:30
|
|
|
sdoc.paragraph(_("Other events in %(year)d") %
|
|
|
|
{"year":main_date.get_year()})
|
2008-04-18 06:39:32 +05:30
|
|
|
yeartab.write(sdoc)
|
2007-12-30 21:09:00 +05:30
|
|
|
else:
|
|
|
|
sdoc.paragraph(_("No other events in %(year)d") %
|
|
|
|
{"year":main_date.get_year()})
|
|
|
|
sdoc.paragraph("")
|
|
|
|
sdoc.paragraph("")
|