2009-02-02 19:57:40 +05:30
|
|
|
#!/usr/bin/python
|
|
|
|
# -*- coding: utf-8 -*-
|
2008-07-23 13:08:16 +05:30
|
|
|
#
|
|
|
|
# Gramps - a GTK+/GNOME based genealogy program
|
|
|
|
#
|
|
|
|
# Copyright (C) 2006-2007 Alex Roitman
|
2009-02-10 18:53:11 +05:30
|
|
|
# Copyright (C) 2007-2009 Jerome Rapinat
|
2008-07-23 13:08:16 +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-02 19:57:40 +05:30
|
|
|
# -------------------------------------------------------------------------
|
2008-07-23 13:08:16 +05:30
|
|
|
#
|
|
|
|
# gramps modules
|
|
|
|
#
|
2009-02-02 19:57:40 +05:30
|
|
|
# -------------------------------------------------------------------------
|
2008-07-23 13:08:16 +05:30
|
|
|
|
2009-02-02 19:57:40 +05:30
|
|
|
"""
|
|
|
|
Display RepoRef for sources related to active repository
|
|
|
|
"""
|
|
|
|
|
2009-04-28 16:24:04 +05:30
|
|
|
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
2010-01-18 10:12:17 +05:30
|
|
|
from gen.ggettext import gettext as _
|
2009-02-02 19:57:40 +05:30
|
|
|
|
2008-07-23 13:08:16 +05:30
|
|
|
def run(database, document, repo):
|
2009-02-10 18:53:11 +05:30
|
|
|
"""
|
|
|
|
Display back-references (sources) for this repository.
|
|
|
|
"""
|
2008-07-23 13:08:16 +05:30
|
|
|
|
2009-04-28 16:24:04 +05:30
|
|
|
# setup the simple access functions
|
|
|
|
|
|
|
|
sdb = SimpleAccess(database)
|
2008-07-23 13:08:16 +05:30
|
|
|
sdoc = SimpleDoc(document)
|
2009-04-28 16:24:04 +05:30
|
|
|
stab = SimpleTable(sdb)
|
2009-02-02 19:57:40 +05:30
|
|
|
|
2008-07-23 13:08:16 +05:30
|
|
|
# First we find repository and add its text
|
2009-02-02 19:57:40 +05:30
|
|
|
|
|
|
|
sdoc.title('%s\n' % repo.get_name())
|
|
|
|
|
|
|
|
# Go over all the sources that refer to this repository
|
|
|
|
|
2008-07-23 13:08:16 +05:30
|
|
|
repo_handle = repo.handle
|
2009-02-02 19:57:40 +05:30
|
|
|
source_list = [item[1] for item in
|
|
|
|
database.find_backlink_handles(repo_handle, ['Source'
|
|
|
|
])]
|
|
|
|
|
|
|
|
for source_handle in source_list:
|
2008-07-23 13:08:16 +05:30
|
|
|
src = database.get_source_from_handle(source_handle)
|
2009-02-02 19:57:40 +05:30
|
|
|
|
|
|
|
# Get the list of references from this source to our repo
|
2008-07-23 13:08:16 +05:30
|
|
|
# (can be more than one, technically)
|
2009-02-02 19:57:40 +05:30
|
|
|
|
2008-07-23 13:08:16 +05:30
|
|
|
for reporef in src.get_reporef_list():
|
|
|
|
if reporef.ref == repo_handle:
|
2009-02-02 19:57:40 +05:30
|
|
|
|
2008-07-23 13:08:16 +05:30
|
|
|
# Determine the text for this source
|
2009-02-02 19:57:40 +05:30
|
|
|
|
|
|
|
media = str(reporef.get_media_type())
|
|
|
|
call = reporef.get_call_number()
|
2009-04-28 16:24:04 +05:30
|
|
|
|
|
|
|
stab.columns(_("Source"), _("Type of media"), _("Call number"))
|
|
|
|
stab.row(src.get_title(), media, call)
|
|
|
|
stab.write(sdoc)
|