Added 'Link References' quickview; added a get_link to SimpleAccess
svn: r15348
This commit is contained in:
parent
6846befb21
commit
99c4671e3e
@ -483,6 +483,7 @@ src/plugins/quickview/OnThisDay.py
|
|||||||
#src/plugins/quickview/Query.py
|
#src/plugins/quickview/Query.py
|
||||||
src/plugins/quickview/quickview.gpr.py
|
src/plugins/quickview/quickview.gpr.py
|
||||||
src/plugins/quickview/References.py
|
src/plugins/quickview/References.py
|
||||||
|
src/plugins/quickview/LinkReferences.py
|
||||||
src/plugins/quickview/Reporef.py
|
src/plugins/quickview/Reporef.py
|
||||||
src/plugins/quickview/SameSurnames.py
|
src/plugins/quickview/SameSurnames.py
|
||||||
src/plugins/quickview/siblings.py
|
src/plugins/quickview/siblings.py
|
||||||
|
@ -919,6 +919,17 @@ class SimpleAccess(object):
|
|||||||
else:
|
else:
|
||||||
return "Error: invalid object class: '%s'" % object_class
|
return "Error: invalid object class: '%s'" % object_class
|
||||||
|
|
||||||
|
def get_link(self, object_class, prop, value):
|
||||||
|
"""
|
||||||
|
Given a object_class, prop, and value return the object.
|
||||||
|
object_class is "Person", "Source", etc.
|
||||||
|
prop is "gramps_id", or "handle"
|
||||||
|
value is a gramps_id or handle.
|
||||||
|
"""
|
||||||
|
if object_class in self.dbase.get_table_names():
|
||||||
|
return self.dbase.get_table_metadata(object_class) \
|
||||||
|
[prop + "_func"](value)
|
||||||
|
|
||||||
def by_date(event1, event2):
|
def by_date(event1, event2):
|
||||||
"""
|
"""
|
||||||
Sort function that will compare two events by their dates.
|
Sort function that will compare two events by their dates.
|
||||||
|
73
src/plugins/quickview/LinkReferences.py
Normal file
73
src/plugins/quickview/LinkReferences.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
#
|
||||||
|
# Gramps - a GTK+/GNOME based genealogy program
|
||||||
|
#
|
||||||
|
# Copyright (C) 2010 Doug Blank <doug.blank@gmail.com>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# $Id: $
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
Display link references for a note
|
||||||
|
"""
|
||||||
|
|
||||||
|
from Simple import SimpleAccess, SimpleDoc, SimpleTable
|
||||||
|
from gen.lib import StyledTextTagType
|
||||||
|
from gen.ggettext import gettext as _
|
||||||
|
|
||||||
|
def run(database, document, obj):
|
||||||
|
"""
|
||||||
|
Display link references for this note.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# setup the simple access functions
|
||||||
|
sdb = SimpleAccess(database)
|
||||||
|
sdoc = SimpleDoc(document)
|
||||||
|
stab = SimpleTable(sdb)
|
||||||
|
|
||||||
|
# display the title
|
||||||
|
sdoc.title(_("Link References for this note"))
|
||||||
|
sdoc.paragraph("\n")
|
||||||
|
stab.columns(_("Type"), _("Reference"), _("Link check"))
|
||||||
|
|
||||||
|
tags = obj.text.get_tags()
|
||||||
|
|
||||||
|
for styledtext_tag in tags:
|
||||||
|
if int(styledtext_tag.name) == StyledTextTagType.LINK:
|
||||||
|
if styledtext_tag.value.startswith("gramps://"):
|
||||||
|
object_class, prop, value = styledtext_tag.value[9:].split("/", 2)
|
||||||
|
tagtype = _("Gramps")
|
||||||
|
ref_obj = sdb.get_link(object_class, prop, value)
|
||||||
|
if ref_obj:
|
||||||
|
tagvalue = ref_obj
|
||||||
|
tagcheck = _("Ok")
|
||||||
|
else:
|
||||||
|
tagvalue = styledtext_tag.value
|
||||||
|
tagcheck = _("Failed: missing object")
|
||||||
|
else:
|
||||||
|
tagtype = _("Internet")
|
||||||
|
tagvalue = styledtext_tag.value
|
||||||
|
tagcheck = ""
|
||||||
|
stab.row(tagtype, tagvalue, tagcheck)
|
||||||
|
|
||||||
|
if stab.get_row_count() > 0:
|
||||||
|
stab.write(sdoc)
|
||||||
|
else:
|
||||||
|
sdoc.paragraph(_("No link references for this note"))
|
||||||
|
sdoc.paragraph("")
|
||||||
|
sdoc.paragraph("")
|
||||||
|
|
@ -15,6 +15,7 @@ pkgdata_PYTHON = \
|
|||||||
OnThisDay.py \
|
OnThisDay.py \
|
||||||
quickview.gpr.py \
|
quickview.gpr.py \
|
||||||
References.py \
|
References.py \
|
||||||
|
LinkReferences.py \
|
||||||
Reporef.py \
|
Reporef.py \
|
||||||
SameSurnames.py\
|
SameSurnames.py\
|
||||||
siblings.py
|
siblings.py
|
||||||
|
@ -219,6 +219,20 @@ for (category, item, trans) in refitems:
|
|||||||
runfunc = 'run_%s' % item
|
runfunc = 'run_%s' % item
|
||||||
)
|
)
|
||||||
|
|
||||||
|
register(QUICKREPORT,
|
||||||
|
id = 'link_references',
|
||||||
|
name = _("Link References"),
|
||||||
|
description = _("Display link references for a note"),
|
||||||
|
version = '1.0',
|
||||||
|
gramps_target_version = '3.3',
|
||||||
|
status = STABLE,
|
||||||
|
fname = 'LinkReferences.py',
|
||||||
|
authors = ["Douglas Blank"],
|
||||||
|
authors_email = ["doug.blank@gmail.com"],
|
||||||
|
category = CATEGORY_QR_NOTE,
|
||||||
|
runfunc = 'run'
|
||||||
|
)
|
||||||
|
|
||||||
#------------------------------------------------------------------------
|
#------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Show Repository Reference
|
# Show Repository Reference
|
||||||
|
Loading…
Reference in New Issue
Block a user