1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
1 |
#
|
2 |
# Gramps - a GTK+/GNOME based genealogy program
|
|
3 |
#
|
|
4 |
# Copyright (C) 2000-2007 Donald N. Allingham
|
|
5 |
# Copyright (C) 2007-2008 Brian G. Matherly
|
|
1.1.26
by James A. Treacy
Import upstream version 3.4.0 |
6 |
# Copyright (C) 2011 Tim G L Lyons
|
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
7 |
#
|
8 |
# This program is free software; you can redistribute it and/or modify
|
|
9 |
# it under the terms of the GNU General Public License as published by
|
|
10 |
# the Free Software Foundation; either version 2 of the License, or
|
|
11 |
# (at your option) any later version.
|
|
12 |
#
|
|
13 |
# This program is distributed in the hope that it will be useful,
|
|
14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
16 |
# GNU General Public License for more details.
|
|
17 |
#
|
|
18 |
# You should have received a copy of the GNU General Public License
|
|
19 |
# along with this program; if not, write to the Free Software
|
|
20 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
21 |
#
|
|
1.3.5
by James A. Treacy
Import upstream version 3.2.0 |
22 |
#
|
1.1.26
by James A. Treacy
Import upstream version 3.4.0 |
23 |
# $Id: References.py 18548 2011-12-04 17:09:17Z kulath $
|
1.3.5
by James A. Treacy
Import upstream version 3.2.0 |
24 |
#
|
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
25 |
|
26 |
"""
|
|
27 |
Display references for any object
|
|
28 |
"""
|
|
29 |
||
30 |
from Simple import SimpleAccess, SimpleDoc, SimpleTable |
|
1.3.5
by James A. Treacy
Import upstream version 3.2.0 |
31 |
from gen.ggettext import gettext as _ |
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
32 |
|
33 |
def get_ref(db, objclass, handle): |
|
34 |
"""
|
|
35 |
Looks up object in database
|
|
36 |
"""
|
|
37 |
if objclass == 'Person': |
|
38 |
ref = db.get_person_from_handle(handle) |
|
39 |
elif objclass == 'Family': |
|
40 |
ref = db.get_family_from_handle(handle) |
|
41 |
elif objclass == 'Event': |
|
42 |
ref = db.get_event_from_handle(handle) |
|
43 |
elif objclass == 'Source': |
|
44 |
ref = db.get_source_from_handle(handle) |
|
1.1.26
by James A. Treacy
Import upstream version 3.4.0 |
45 |
elif objclass == 'Citation': |
46 |
ref = db.get_citation_from_handle(handle) |
|
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
47 |
elif objclass == 'Place': |
48 |
ref = db.get_place_from_handle(handle) |
|
1.3.5
by James A. Treacy
Import upstream version 3.2.0 |
49 |
elif objclass == 'Note': |
50 |
ref = db.get_note_from_handle(handle) |
|
51 |
elif objclass in ['MediaObject', 'Media']: |
|
52 |
ref = db.get_object_from_handle(handle) |
|
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
53 |
else: |
54 |
ref = objclass |
|
55 |
return ref |
|
56 |
||
57 |
def run(database, document, object, item, trans): |
|
58 |
"""
|
|
59 |
Display back-references for this object.
|
|
60 |
"""
|
|
61 |
||
62 |
# setup the simple access functions
|
|
63 |
sdb = SimpleAccess(database) |
|
64 |
sdoc = SimpleDoc(document) |
|
65 |
stab = SimpleTable(sdb) |
|
66 |
||
67 |
# display the title
|
|
68 |
sdoc.title(_("References for this %s") % trans) |
|
69 |
sdoc.paragraph("\n") |
|
70 |
stab.columns(_("Type"), _("Reference")) |
|
71 |
for (objclass, handle) in database.find_backlink_handles(object.handle): |
|
72 |
ref = get_ref(database, objclass, handle) |
|
73 |
stab.row(_(objclass), ref) # translation are explicit (above) |
|
74 |
||
75 |
if stab.get_row_count() > 0: |
|
1.1.23
by James A. Treacy
Import upstream version 3.3.0 |
76 |
document.has_data = True |
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
77 |
stab.write(sdoc) |
78 |
else: |
|
1.1.23
by James A. Treacy
Import upstream version 3.3.0 |
79 |
document.has_data = False |
1.2.6
by James A. Treacy
Import upstream version 3.1.0 |
80 |
sdoc.paragraph(_("No references for this %s") % trans) |
81 |
sdoc.paragraph("") |
|
82 |
sdoc.paragraph("") |
|
83 |
||
1.3.5
by James A. Treacy
Import upstream version 3.2.0 |
84 |
#functions for the actual quickreports
|
85 |
run_person = lambda db, doc, obj: run(db, doc, obj, 'person', _("Person")) |
|
86 |
run_family = lambda db, doc, obj: run(db, doc, obj, 'family', _("Family")) |
|
87 |
run_event = lambda db, doc, obj: run(db, doc, obj, 'event', _("Event")) |
|
88 |
run_source = lambda db, doc, obj: run(db, doc, obj, 'source', _("Source")) |
|
1.1.26
by James A. Treacy
Import upstream version 3.4.0 |
89 |
run_citation = lambda db, doc, obj: run(db, doc, obj, 'citation', _("Citation")) |
90 |
run_source_or_citation = lambda db, doc, obj: run(db, doc, obj, |
|
91 |
'source or citation', _("Source or Citation")) |
|
1.3.5
by James A. Treacy
Import upstream version 3.2.0 |
92 |
run_place = lambda db, doc, obj: run(db, doc, obj, 'place', _("Place")) |
93 |
run_media = lambda db, doc, obj: run(db, doc, obj, 'media', _("Media")) |
|
94 |
run_note = lambda db, doc, obj: run(db, doc, obj, 'note', _("Note")) |