Move labels into schema

This commit is contained in:
Nick Hall 2017-02-20 16:24:09 +00:00
parent 6a6d0c3a2e
commit e46321a7c6
17 changed files with 330 additions and 433 deletions

View File

@ -44,6 +44,8 @@ from .datebase import DateBase
from .tagbase import TagBase from .tagbase import TagBase
from .attrbase import SrcAttributeBase from .attrbase import SrcAttributeBase
from .citationbase import IndirectCitationBase from .citationbase import IndirectCitationBase
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
LOG = logging.getLogger(".citation") LOG = logging.getLogger(".citation")
@ -92,51 +94,46 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
from .date import Date from .date import Date
return { return {
"type": "object", "type": "object",
"title": _("Citation"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, "gramps_id": {"type": "string",
"page": {"type": "string"}, "title": _("Gramps ID")},
"date": {"oneOf": [{"type": "null"}, Date.get_schema()],
"title": _("Date")},
"page": {"type": "string",
"title": _("Page")},
"confidence": {"type": "integer", "confidence": {"type": "integer",
"minimum": 0, "minimum": 0,
"maximum": 4}, "maximum": 4,
"title": _("Confidence")},
"source_handle": {"type": "string", "source_handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"title": _("Source")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Notes")},
"media_list": {"type": "array", "media_list": {"type": "array",
"items": MediaRef.get_schema()}, "items": MediaRef.get_schema(),
"title": _("Media")},
"srcattr_list": {"type": "array", "srcattr_list": {"type": "array",
"items": SrcAttribute.get_schema()}, "items": SrcAttribute.get_schema(),
"change": {"type": "integer"}, "title": _("Source Attributes")},
"change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }
@classmethod
def get_labels(cls, _):
return {
"_class": _("Citation"),
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"date": _("Date"),
"page": _("Page"),
"confidence": _("Confidence"),
"source_handle": _("Source"),
"note_list": _("Notes"),
"media_list": _("Media"),
"srcattribute_list": _("Source Attributes"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private"),
}
def serialize(self, no_text_date=False): def serialize(self, no_text_date=False):
""" """
Convert the object to a serialized tuple of data. Convert the object to a serialized tuple of data.

View File

@ -46,6 +46,8 @@ from .datebase import DateBase
from .placebase import PlaceBase from .placebase import PlaceBase
from .tagbase import TagBase from .tagbase import TagBase
from .eventtype import EventType from .eventtype import EventType
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
LOG = logging.getLogger(".citation") LOG = logging.getLogger(".citation")
@ -131,53 +133,47 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
from .mediaref import MediaRef from .mediaref import MediaRef
return { return {
"type": "object", "type": "object",
"title": _("Event"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"gramps_id": {"type": "string",
"title": _("Gramps ID")},
"type": EventType.get_schema(), "type": EventType.get_schema(),
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, "date": {"oneOf": [{"type": "null"}, Date.get_schema()],
"description": {"type": "string"}, "title": _("Date")},
"description": {"type": "string",
"title": _("Description")},
"place": {"type": ["string", "null"], "place": {"type": ["string", "null"],
"maxLength": 50}, "maxLength": 50,
"title": _("Place")},
"citation_list": {"type": "array", "citation_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Citations")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Notes")},
"media_list": {"type": "array", "media_list": {"type": "array",
"items": MediaRef.get_schema()}, "items": MediaRef.get_schema(),
"title": _("Media")},
"attribute_list": {"type": "array", "attribute_list": {"type": "array",
"items": Attribute.get_schema()}, "items": Attribute.get_schema(),
"change": {"type": "integer"}, "title": _("Media")},
"change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"}, "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")},
} }
} }
@classmethod
def get_labels(cls, _):
return {
"_class": _("Event"),
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"type": _("Type"),
"date": _("Date"),
"description": _("Description"),
"place": _("Place"),
"citation_list": _("Citations"),
"note_list": _("Notes"),
"media_list": _("Media"),
"attribute_list": _("Attributes"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private"),
}
def unserialize(self, data): def unserialize(self, data):
""" """
Convert the data held in a tuple created by the serialize method Convert the data held in a tuple created by the serialize method

View File

@ -39,6 +39,8 @@ from .refbase import RefBase
from .eventroletype import EventRoleType from .eventroletype import EventRoleType
from .const import IDENTICAL, EQUAL, DIFFERENT from .const import IDENTICAL, EQUAL, DIFFERENT
from .citationbase import IndirectCitationBase from .citationbase import IndirectCitationBase
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -90,37 +92,25 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase,
from .attribute import Attribute from .attribute import Attribute
return { return {
"type": "object", "type": "object",
"title": _("Event reference"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"private": {"type": "boolean"}, "private": {"type": "boolean",
"title": _("Private")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}},
"attribute_list": {"type": "array",
"items": Attribute.get_schema()},
"ref": {"type": "string",
"maxLength": 50}, "maxLength": 50},
"title": _("Notes")},
"attribute_list": {"type": "array",
"items": Attribute.get_schema(),
"title": _("Attributes")},
"ref": {"type": "string",
"maxLength": 50,
"title": _("Event")},
"role": EventRoleType.get_schema(), "role": EventRoleType.get_schema(),
} }
} }
@classmethod
def get_labels(cls, _):
"""
Given a translation function, returns the labels for
each field of this object.
:returns: Returns a dict containing the fields to labels.
:rtype: dict
"""
return {
"private": _("Private"),
"note_list": _("Notes"),
"attribute_list": _("Attributes"),
"ref": _("Event"),
"role": _("Role"),
}
def unserialize(self, data): def unserialize(self, data):
""" """
Convert a serialized tuple of data to an object. Convert a serialized tuple of data to an object.

View File

@ -49,6 +49,8 @@ from .tagbase import TagBase
from .childref import ChildRef from .childref import ChildRef
from .familyreltype import FamilyRelType from .familyreltype import FamilyRelType
from .const import IDENTICAL, EQUAL, DIFFERENT from .const import IDENTICAL, EQUAL, DIFFERENT
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
LOG = logging.getLogger(".citation") LOG = logging.getLogger(".citation")
@ -140,61 +142,55 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
from .attribute import Attribute from .attribute import Attribute
return { return {
"type": "object", "type": "object",
"title": _("Family"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"gramps_id": {"type": "string",
"title": _("Gramps ID")},
"father_handle": {"type": ["string", "null"], "father_handle": {"type": ["string", "null"],
"maxLength": 50}, "maxLength": 50,
"title": _("Father")},
"mother_handle": {"type": ["string", "null"], "mother_handle": {"type": ["string", "null"],
"maxLength": 50}, "maxLength": 50,
"title": _("Mother")},
"child_ref_list": {"type": "array", "child_ref_list": {"type": "array",
"items": ChildRef.get_schema()}, "items": ChildRef.get_schema(),
"title": _("Children")},
"type": FamilyRelType.get_schema(), "type": FamilyRelType.get_schema(),
"event_ref_list": {"type": "array", "event_ref_list": {"type": "array",
"items": EventRef.get_schema()}, "items": EventRef.get_schema(),
"title": _("Events")},
"media_list": {"type": "array", "media_list": {"type": "array",
"items": MediaRef.get_schema()}, "items": MediaRef.get_schema(),
"title": _("Media")},
"attribute_list": {"type": "array", "attribute_list": {"type": "array",
"items": Attribute.get_schema()}, "items": Attribute.get_schema(),
"title": _("Attributes")},
"lds_ord_list": {"type": "array", "lds_ord_list": {"type": "array",
"items": LdsOrd.get_schema()}, "items": LdsOrd.get_schema(),
"title": _("LDS ordinances")},
"citation_list": {"type": "array", "citation_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Citations")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"change": {"type": "integer"}, "title": _("Notes")},
"change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }
@classmethod
def get_labels(cls, _):
return {
"_class": _("Family"),
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"father_handle": _("Father"),
"mother_handle": _("Mother"),
"child_ref_list": _("Children"),
"type": _("Relationship"),
"event_ref_list": _("Events"),
"media_list": _("Media"),
"attribute_list": _("Attributes"),
"lds_ord_list": _("LDS ordinances"),
"citation_list": _("Citations"),
"note_list": _("Notes"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private"),
}
def unserialize(self, data): def unserialize(self, data):
""" """
Convert the data held in a tuple created by the serialize method Convert the data held in a tuple created by the serialize method

View File

@ -218,20 +218,14 @@ class GrampsType(object, metaclass=GrampsTypeMeta):
""" """
return { return {
"type": "object", "type": "object",
"title": _("Type"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"string": {"type": "string"}, "string": {"type": "string",
"title": _("Type")},
} }
} }
@classmethod
def get_labels(cls, _):
return {
"_class": _("Family Relationship"),
"value": _("Family Relationship"),
"string": _("Family Relationship"),
}
def unserialize(self, data): def unserialize(self, data):
"""Convert a serialized tuple of data to an object.""" """Convert a serialized tuple of data to an object."""
self.__value, self.__string = data self.__value, self.__string = data

View File

@ -45,6 +45,8 @@ from .notebase import NoteBase
from .datebase import DateBase from .datebase import DateBase
from .attrbase import AttributeBase from .attrbase import AttributeBase
from .tagbase import TagBase from .tagbase import TagBase
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
LOG = logging.getLogger(".citation") LOG = logging.getLogger(".citation")
@ -129,57 +131,45 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase,
from .date import Date from .date import Date
return { return {
"type": "object", "type": "object",
"title": _("Media"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"path": {"type": "string"}, "gramps_id": {"type": "string",
"mime": {"type": "string"}, "title": _("Gramps ID")},
"desc": {"type": "string"}, "path": {"type": "string",
"checksum": {"type": "string"}, "title": _("Path")},
"mime": {"type": "string",
"title": _("MIME")},
"desc": {"type": "string",
"title": _("Description")},
"checksum": {"type": "string",
"title": _("Checksum")},
"attribute_list": {"type": "array", "attribute_list": {"type": "array",
"items": Attribute.get_schema()}, "items": Attribute.get_schema(),
"title": _("Attributes")},
"citation_list": {"type": "array", "citation_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Citations")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string"}}, "items": {"type": "string"},
"change": {"type": "integer"}, "title": _("Notes")},
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, "change": {"type": "integer",
"title": _("Last changed")},
"date": {"oneOf": [{"type": "null"}, Date.get_schema()],
"title": _("Date")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }
@classmethod
def get_labels(cls, _):
"""
Given a translation function, returns the labels for
each field of this object.
:returns: Returns a dict containing the fields to labels.
:rtype: dict
"""
return {
"_class": _("Media"),
"handle": _("Media"),
"gramps_id": _("Gramps ID"),
"path": _("Path"),
"mime": _("MIME"),
"desc": _("Description"),
"checksum": _("Checksum"),
"attribute_list": _("Attributes"),
"citation_list": _("Citations"),
"note_list": _("Notes"),
"change": _("Last changed"),
"date": _("Date"),
"tag_list": _("Tags"),
"private": _("Private"),
}
def unserialize(self, data): def unserialize(self, data):
""" """
Convert the data held in a tuple created by the serialize method Convert the data held in a tuple created by the serialize method

View File

@ -40,7 +40,7 @@ from .surnamebase import SurnameBase
from .nametype import NameType from .nametype import NameType
from .const import IDENTICAL, EQUAL, DIFFERENT from .const import IDENTICAL, EQUAL, DIFFERENT
from .date import Date from .date import Date
from gramps.gen.const import GRAMPS_LOCALE as glocale from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext _ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
@ -129,27 +129,6 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
self.group_as, self.sort_as, self.display_as, self.call, self.group_as, self.sort_as, self.display_as, self.call,
self.nick, self.famnick) self.nick, self.famnick)
@classmethod
def get_labels(cls, _):
return {
"_class": _("Name"),
"private": _("Private"),
"citation_list": _("Citations"),
"note_list": _("Notes"),
"date": _("Date"),
"first_name": _("Given name"),
"surname_list": _("Surnames"),
"suffix": _("Suffix"),
"title": _("Title"),
"type": _("Type"),
"group_as": _("Group as"),
"sort_as": _("Sort as"),
"display_as": _("Display as"),
"call": _("Call name"),
"nick": _("Nick name"),
"famnick": _("Family nick name"),
}
@classmethod @classmethod
def get_schema(cls): def get_schema(cls):
""" """
@ -161,28 +140,43 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
from .surname import Surname from .surname import Surname
return { return {
"type": "object", "type": "object",
"title": _("Name"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"private": {"type": "boolean"}, "private": {"type": "boolean",
"title": _("Private")},
"citation_list": {"type": "array", "citation_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Citations")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"date": {"oneOf": [{"type": "null"}, Date.get_schema()]}, "title": _("Notes")},
"first_name": {"type": "string"}, "date": {"oneOf": [{"type": "null"}, Date.get_schema()],
"title": _("Date")},
"first_name": {"type": "string",
"title": _("Given name")},
"surname_list": {"type": "array", "surname_list": {"type": "array",
"items": Surname.get_schema()}, "items": Surname.get_schema(),
"suffix": {"type": "string"}, "title": _("Surnames")},
"title": {"type": "string"}, "suffix": {"type": "string",
"title": _("Suffix")},
"title": {"type": "string",
"title": _("Title")},
"type": NameType.get_schema(), "type": NameType.get_schema(),
"group_as": {"type": "string"}, "group_as": {"type": "string",
"sort_as": {"type": "integer"}, "title": _("Group as")},
"display_as": {"type": "integer"}, "sort_as": {"type": "integer",
"call": {"type": "string"}, "title": _("Sort as")},
"nick": {"type": "string"}, "display_as": {"type": "integer",
"famnick": {"type": "string"} "title": _("Display as")},
"call": {"type": "string",
"title": _("Call name")},
"nick": {"type": "string",
"title": _("Nick name")},
"famnick": {"type": "string",
"title": _("Family nick name")}
} }
} }

View File

@ -34,6 +34,8 @@ 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 .styledtexttagtype import StyledTextTagType
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -104,35 +106,29 @@ class Note(BasicPrimaryObject):
""" """
return { return {
"type": "object", "type": "object",
"title": _("Note"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": ("Handle")},
"gramps_id": {"type": "string",
"title": _("Gramps ID")},
"text": StyledText.get_schema(), "text": StyledText.get_schema(),
"format": {"type": "integer"}, "format": {"type": "integer",
"title": _("Format")},
"type": NoteType.get_schema(), "type": NoteType.get_schema(),
"change": {"type": "integer"}, "change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }
@classmethod
def get_labels(cls, _):
return {
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"text": _("Text"),
"format": _("Format"),
"type": _("Type"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private"),
}
def unserialize(self, data): def unserialize(self, data):
"""Convert a serialized tuple of data to an object. """Convert a serialized tuple of data to an object.

View File

@ -156,33 +156,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
[pr.serialize() for pr in self.person_ref_list] # 20 [pr.serialize() for pr in self.person_ref_list] # 20
) )
@classmethod
def get_labels(cls, _):
return {
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"gender": _("Gender"),
"primary_name": _("Primary name"),
"alternate_names": _("Alternate names"),
"death_ref_index": _("Death reference index"),
"birth_ref_index": _("Birth reference index"),
"event_ref_list": _("Event references"),
"family_list": _("Families"),
"parent_family_list": _("Parent families"),
"media_list": _("Media"),
"address_list": _("Addresses"),
"attribute_list": _("Attributes"),
"urls": _("Urls"),
"lds_ord_list": _("LDS ordinances"),
"citation_list": _("Citations"),
"note_list": _("Notes"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private"),
"person_ref_list": _("Person references"),
"probably_alive": _("Probably alive"),
}
@classmethod @classmethod
def get_schema(cls): def get_schema(cls):
""" """
@ -197,50 +170,71 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
from .ldsord import LdsOrd from .ldsord import LdsOrd
return { return {
"type": "object", "type": "object",
"title": _("Person"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"gramps_id": {"type": "string",
"title": _("Gramps ID")},
"gender": {"type": "integer", "gender": {"type": "integer",
"minimum": 0, "minimum": 0,
"maximum": 2}, "maximum": 2,
"title": _("Gender")},
"primary_name": Name.get_schema(), "primary_name": Name.get_schema(),
"alternate_names": {"type": "array", "alternate_names": {"type": "array",
"items": Name.get_schema()}, "items": Name.get_schema(),
"death_ref_index": {"type": "integer"}, "title": _("Alternate names")},
"birth_ref_index": {"type": "integer"}, "death_ref_index": {"type": "integer",
"title": _("Death reference index")},
"birth_ref_index": {"type": "integer",
"title": _("Birth reference index")},
"event_ref_list": {"type": "array", "event_ref_list": {"type": "array",
"items": EventRef.get_schema()}, "items": EventRef.get_schema(),
"title": _("Event references")},
"family_list": {"type": "array", "family_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Families")},
"parent_family_list": {"type": "array", "parent_family_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Parent families")},
"media_list": {"type": "array", "media_list": {"type": "array",
"items": MediaRef.get_schema()}, "items": MediaRef.get_schema(),
"title": _("Media")},
"address_list": {"type": "array", "address_list": {"type": "array",
"items": Address.get_schema()}, "items": Address.get_schema(),
"title": _("Addresses")},
"attribute_list": {"type": "array", "attribute_list": {"type": "array",
"items": Attribute.get_schema()}, "items": Attribute.get_schema(),
"title": _("Attributes")},
"urls": {"type": "array", "urls": {"type": "array",
"items": Url.get_schema()}, "items": Url.get_schema(),
"title": _("Urls")},
"lds_ord_list": {"type": "array", "lds_ord_list": {"type": "array",
"items": LdsOrd.get_schema()}, "items": LdsOrd.get_schema(),
"title": _("LDS ordinances")},
"citation_list": {"type": "array", "citation_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Citations")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"change": {"type": "integer"}, "title": _("Notes")},
"change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"}, "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")},
"person_ref_list": {"type": "array", "person_ref_list": {"type": "array",
"items": PersonRef.get_schema()} "items": PersonRef.get_schema(),
"title": _("Person references")}
} }
} }

View File

@ -41,6 +41,8 @@ from .mediabase import MediaBase
from .urlbase import UrlBase from .urlbase import UrlBase
from .tagbase import TagBase from .tagbase import TagBase
from .location import Location from .location import Location
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -118,28 +120,6 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
self.change, TagBase.serialize(self), self.private) self.change, TagBase.serialize(self), self.private)
@classmethod @classmethod
def get_labels(cls, _):
return {
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"title": _("Title"),
"long": _("Longitude"),
"lat": _("Latitude"),
"placeref_list": _("Places"),
"name": _("Name"),
"alt_names": _("Alternate Names"),
"place_type": _("Type"),
"code": _("Code"),
"alt_loc": _("Alternate Locations"),
"urls": _("URLs"),
"media_list": _("Media"),
"citation_list": _("Citations"),
"note_list": _("Notes"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private")
}
@classmethod
def get_schema(cls): def get_schema(cls):
""" """
Returns the JSON Schema for this class. Returns the JSON Schema for this class.
@ -151,38 +131,55 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
from .mediaref import MediaRef from .mediaref import MediaRef
return { return {
"type": "object", "type": "object",
"title": _("Place"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"title": {"type": "string"}, "gramps_id": {"type": "string",
"long": {"type": "string"}, "title": _("Gramps ID")},
"lat": {"type": "string"}, "title": {"type": "string",
"title": _("Title")},
"long": {"type": "string",
"title": _("Longitude")},
"lat": {"type": "string",
"title": _("Latitude")},
"placeref_list": {"type": "array", "placeref_list": {"type": "array",
"items": PlaceRef.get_schema()}, "items": PlaceRef.get_schema(),
"title": _("Places")},
"name": PlaceName.get_schema(), "name": PlaceName.get_schema(),
"alt_names": {"type": "array", "alt_names": {"type": "array",
"items": PlaceName.get_schema()}, "items": PlaceName.get_schema(),
"title": _("Alternate Names")},
"place_type": PlaceType.get_schema(), "place_type": PlaceType.get_schema(),
"code": {"type": "string"}, "code": {"type": "string",
"title": _("Code")},
"alt_loc": {"type": "array", "alt_loc": {"type": "array",
"items": Location.get_schema()}, "items": Location.get_schema(),
"title": _("Alternate Locations")},
"urls": {"type": "array", "urls": {"type": "array",
"items": Url.get_schema()}, "items": Url.get_schema(),
"title": _("URLs")},
"media_list": {"type": "array", "media_list": {"type": "array",
"items": MediaRef.get_schema()}, "items": MediaRef.get_schema(),
"title": _("Media")},
"citation_list": {"type": "array", "citation_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Citations")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"change": {"type": "integer"}, "title": _("Notes")},
"change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }

View File

@ -37,6 +37,8 @@ from .urlbase import UrlBase
from .tagbase import TagBase from .tagbase import TagBase
from .repotype import RepositoryType from .repotype import RepositoryType
from .citationbase import IndirectCitationBase from .citationbase import IndirectCitationBase
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -69,21 +71,6 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase,
UrlBase.serialize(self), UrlBase.serialize(self),
self.change, TagBase.serialize(self), self.private) self.change, TagBase.serialize(self), self.private)
@classmethod
def get_labels(cls, _):
return {
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"type": _("Type"),
"name": _("Name"),
"note_list": _("Notes"),
"address_list": _("Addresses"),
"urls": _("URLs"),
"change": _("Last changed"),
"tag_list": _("Tags"),
"private": _("Private")
}
@classmethod @classmethod
def get_schema(cls): def get_schema(cls):
""" """
@ -96,25 +83,35 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase,
from .url import Url from .url import Url
return { return {
"type": "object", "type": "object",
"title": _("Repository"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"gramps_id": {"type": "string",
"title": _("Gramps ID")},
"type": RepositoryType.get_schema(), "type": RepositoryType.get_schema(),
"name": {"type": "string"}, "name": {"type": "string",
"title": _("Name")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Notes")},
"address_list": {"type": "array", "address_list": {"type": "array",
"items": Address.get_schema()}, "items": Address.get_schema(),
"title": _("Addresses")},
"urls": {"type": "array", "urls": {"type": "array",
"items": Url.get_schema()}, "items": Url.get_schema(),
"change": {"type": "integer"}, "title": _("URLs")},
"change": {"type": "integer",
"title": _("Last changed")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }

View File

@ -69,27 +69,3 @@ class SecondaryObject(BaseObject):
Should be overwritten by objects that inherit from this class. Should be overwritten by objects that inherit from this class.
""" """
pass pass
@classmethod
def get_labels(cls, _):
"""
Return labels.
"""
return {}
def get_label(self, field, _):
"""
Get the associated label given a field name of this object.
"""
chain = field.split(".")
path = self
for part in chain[:-1]:
if hasattr(path, part):
path = getattr(path, part)
else:
path = path[int(part)]
labels = path.get_labels(_)
if chain[-1] in labels:
return labels[chain[-1]]
else:
raise Exception("%s has no such label: '%s'" % (self, field))

View File

@ -39,6 +39,8 @@ from .attrbase import SrcAttributeBase
from .reporef import RepoRef from .reporef import RepoRef
from .const import DIFFERENT, EQUAL, IDENTICAL from .const import DIFFERENT, EQUAL, IDENTICAL
from .citationbase import IndirectCitationBase from .citationbase import IndirectCitationBase
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -79,24 +81,6 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
TagBase.serialize(self), # 11 TagBase.serialize(self), # 11
self.private) # 12 self.private) # 12
@classmethod
def get_labels(cls, _):
return {
"handle": _("Handle"),
"gramps_id": _("Gramps ID"),
"title": _("Title"),
"author": _("Author"),
"pubinfo": _("Publication info"),
"note_list": _("Notes"),
"media_list": _("Media"),
"abbrev": _("Abbreviation"),
"change": _("Last changed"),
"srcattr_list": _("Source Attributes"),
"reporef_list": _("Repositories"),
"tag_list": _("Tags"),
"private": _("Private")
}
@classmethod @classmethod
def get_schema(cls): def get_schema(cls):
""" """
@ -110,29 +94,43 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase,
from .mediaref import MediaRef from .mediaref import MediaRef
return { return {
"type": "object", "type": "object",
"title": _("Source"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"gramps_id": {"type": "string"}, "title": _("Handle")},
"title": {"type": "string"}, "gramps_id": {"type": "string",
"author": {"type": "string"}, "title": _("Gramps ID")},
"pubinfo": {"type": "string"}, "title": {"type": "string",
"title": _("Title")},
"author": {"type": "string",
"title": _("Author")},
"pubinfo": {"type": "string",
"title": _("Publication info")},
"note_list": {"type": "array", "note_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"title": _("Notes")},
"media_list": {"type": "array", "media_list": {"type": "array",
"items": MediaRef.get_schema()}, "items": MediaRef.get_schema(),
"abbrev": {"type": "string"}, "title": _("Media")},
"change": {"type": "integer"}, "abbrev": {"type": "string",
"title": _("Abbreviation")},
"change": {"type": "integer",
"title": _("Last changed")},
"srcattr_list": {"type": "array", "srcattr_list": {"type": "array",
"items": SrcAttribute.get_schema()}, "items": SrcAttribute.get_schema(),
"title": _("Source Attributes")},
"reporef_list": {"type": "array", "reporef_list": {"type": "array",
"items": RepoRef.get_schema()}, "items": RepoRef.get_schema(),
"title": _("Repositories")},
"tag_list": {"type": "array", "tag_list": {"type": "array",
"items": {"type": "string", "items": {"type": "string",
"maxLength": 50}}, "maxLength": 50},
"private": {"type": "boolean"} "title": _("Tags")},
"private": {"type": "boolean",
"title": _("Private")}
} }
} }

View File

@ -28,6 +28,8 @@
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from .styledtexttag import StyledTextTag from .styledtexttag import StyledTextTag
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -299,21 +301,17 @@ class StyledText:
""" """
return { return {
"type": "object", "type": "object",
"title": _("Styled Text"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"string": {"type": "string"}, "string": {"type": "string",
"title": _("Text")},
"tags": {"type": "array", "tags": {"type": "array",
"items": StyledTextTag.get_schema()} "items": StyledTextTag.get_schema(),
"title": _("Styled Text Tags")}
} }
} }
@classmethod
def get_labels(cls, _):
return {
"string": _("Text"),
"tags": _("Styled Text Tags"),
}
def unserialize(self, data): def unserialize(self, data):
""" """
Convert a serialized tuple of data to an object. Convert a serialized tuple of data to an object.

View File

@ -32,6 +32,8 @@ Surname class for Gramps.
from .secondaryobj import SecondaryObject from .secondaryobj import SecondaryObject
from .nameorigintype import NameOriginType from .nameorigintype import NameOriginType
from .const import IDENTICAL, EQUAL, DIFFERENT from .const import IDENTICAL, EQUAL, DIFFERENT
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -82,27 +84,21 @@ class Surname(SecondaryObject):
""" """
return { return {
"type": "object", "type": "object",
"title": _("Surname"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"surname": {"type": "string"}, "surname": {"type": "string",
"prefix": {"type": "string"}, "title": _("Surname")},
"primary": {"type": "boolean"}, "prefix": {"type": "string",
"title": _("Prefix")},
"primary": {"type": "boolean",
"title": _("Primary")},
"origintype": NameOriginType.get_schema(), "origintype": NameOriginType.get_schema(),
"connector": {"type": "string"} "connector": {"type": "string",
"title": _("Connector")}
} }
} }
@classmethod
def get_labels(cls, _):
return {
"_class": _("Surname"),
"surname": _("Surname"),
"prefix": _("Prefix"),
"primary": _("Primary"),
"origintype": _("Origin type"),
"connector": _("Connector")
}
def is_empty(self): def is_empty(self):
""" """
Indicate if the surname is empty. Indicate if the surname is empty.

View File

@ -148,13 +148,6 @@ class TableObject(BaseObject):
""" """
return self.handle return self.handle
@classmethod
def get_labels(cls, _):
"""
Return labels.
"""
return {}
@classmethod @classmethod
def get_schema(cls): def get_schema(cls):
""" """

View File

@ -29,6 +29,8 @@ Tag object for Gramps.
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
from .tableobj import TableObject from .tableobj import TableObject
from ..const import GRAMPS_LOCALE as glocale
_ = glocale.translation.gettext
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
# #
@ -110,32 +112,25 @@ class Tag(TableObject):
""" """
return { return {
"type": "object", "type": "object",
"title": _("Tag"),
"properties": { "properties": {
"_class": {"enum": [cls.__name__]}, "_class": {"enum": [cls.__name__]},
"handle": {"type": "string", "handle": {"type": "string",
"maxLength": 50}, "maxLength": 50,
"name": {"type": "string"}, "title": _("Handle")},
"name": {"type": "string",
"title": _("Name")},
"color": {"type": "string", "color": {"type": "string",
"maxLength": 13}, "maxLength": 13,
"title": _("Color")},
"priority": {"type": "integer", "priority": {"type": "integer",
"minimum": 0}, "minimum": 0,
"change": {"type": "integer"} "title": _("Priority")},
"change": {"type": "integer",
"title": _("Last changed")}
} }
} }
@classmethod
def get_labels(cls, _):
"""
Return the label for fields
"""
return {
"handle": _("Handle"),
"name": _("Name"),
"color": _("Color"),
"priority": _("Priority"),
"change": _("Last changed"),
}
def get_text_data_list(self): def get_text_data_list(self):
""" """
Return the list of all textual attributes of the object. Return the list of all textual attributes of the object.