Moved code to get links from notes to Note object; updated quickview
svn: r23382
This commit is contained in:
parent
39a3f50a96
commit
365daaba62
@ -35,6 +35,7 @@ from .primaryobj import BasicPrimaryObject
|
|||||||
from .tagbase import TagBase
|
from .tagbase import TagBase
|
||||||
from .notetype import NoteType
|
from .notetype import NoteType
|
||||||
from .styledtext import StyledText
|
from .styledtext import StyledText
|
||||||
|
from .styledtexttagtype import StyledTextTagType
|
||||||
from ..constfunc import cuni
|
from ..constfunc import cuni
|
||||||
from .handle import Handle
|
from .handle import Handle
|
||||||
|
|
||||||
@ -257,3 +258,25 @@ class Note(BasicPrimaryObject):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
return self.type
|
return self.type
|
||||||
|
|
||||||
|
def get_links(self):
|
||||||
|
"""
|
||||||
|
Get the jump links from this note. Links can be external, to
|
||||||
|
urls, or can be internal to gramps objects.
|
||||||
|
|
||||||
|
Return examples:
|
||||||
|
[("gramps", "Person", "handle", "7657626365362536"),
|
||||||
|
("external", "www", "url", "http://example.com")]
|
||||||
|
|
||||||
|
:returns: list of [(domain, type, propery, value), ...]
|
||||||
|
:rtype: list
|
||||||
|
"""
|
||||||
|
retval = []
|
||||||
|
for styledtext_tag in self.text.get_tags():
|
||||||
|
if int(styledtext_tag.name) == StyledTextTagType.LINK:
|
||||||
|
if styledtext_tag.value.startswith("gramps://"):
|
||||||
|
object_class, prop, value = styledtext_tag.value[9:].split("/", 2)
|
||||||
|
retval.append(("gramps", object_class, prop, value))
|
||||||
|
else:
|
||||||
|
retval.append(("external", "www", "url", styledtext_tag.value))
|
||||||
|
return retval
|
||||||
|
@ -46,14 +46,10 @@ def run(database, document, obj):
|
|||||||
sdoc.paragraph("\n")
|
sdoc.paragraph("\n")
|
||||||
stab.columns(_("Type"), _("Reference"), _("Link check"))
|
stab.columns(_("Type"), _("Reference"), _("Link check"))
|
||||||
|
|
||||||
tags = obj.text.get_tags()
|
for (ldomain, ltype, lprop, lvalue) in obj.get_links():
|
||||||
|
if ldomain == "gramps":
|
||||||
for styledtext_tag in tags:
|
tagtype = _(ltype)
|
||||||
if int(styledtext_tag.name) == StyledTextTagType.LINK:
|
ref_obj = sdb.get_link(ltype, lprop, lvalue)
|
||||||
if styledtext_tag.value.startswith("gramps://"):
|
|
||||||
object_class, prop, value = styledtext_tag.value[9:].split("/", 2)
|
|
||||||
tagtype = _(object_class)
|
|
||||||
ref_obj = sdb.get_link(object_class, prop, value)
|
|
||||||
if ref_obj:
|
if ref_obj:
|
||||||
tagvalue = ref_obj
|
tagvalue = ref_obj
|
||||||
tagcheck = _("Ok")
|
tagcheck = _("Ok")
|
||||||
@ -62,7 +58,7 @@ def run(database, document, obj):
|
|||||||
tagcheck = _("Failed: missing object")
|
tagcheck = _("Failed: missing object")
|
||||||
else:
|
else:
|
||||||
tagtype = _("Internet")
|
tagtype = _("Internet")
|
||||||
tagvalue = styledtext_tag.value
|
tagvalue = lvalue
|
||||||
tagcheck = ""
|
tagcheck = ""
|
||||||
stab.row(tagtype, tagvalue, tagcheck)
|
stab.row(tagtype, tagvalue, tagcheck)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user