From 009aa6349d9fbd24c41c63baf8a95c17cf298388 Mon Sep 17 00:00:00 2001 From: Achim Schumacher Date: Mon, 29 Jul 2019 18:23:18 +0200 Subject: [PATCH 1/3] Added support for multiple unique bones --- bones/email.py | 21 +++++++++++---------- bones/string.py | 26 +++++++++++++++++++++----- 2 files changed, 32 insertions(+), 15 deletions(-) diff --git a/bones/email.py b/bones/email.py index 42adf5df..0afef1a0 100644 --- a/bones/email.py +++ b/bones/email.py @@ -2,8 +2,9 @@ import html5 from priorityqueue import editBoneSelector, viewDelegateSelector import bones.string as strBone -from widgets.edit import InvalidBoneValueException +# from widgets.edit import InvalidBoneValueException import re +# import string as py_string class EmailViewBoneDelegate( strBone.StringViewBoneDelegate ): def __init__(self, moduleName, boneName, skelStructure, *args, **kwargs ): @@ -31,19 +32,19 @@ class EmailEditBone( strBone.StringEditBone ): def __init__(self, moduleName, boneName,readOnly,*args, **kwargs ): super( EmailEditBone, self ).__init__( moduleName, boneName,readOnly, *args, **kwargs ) + @staticmethod + def isInvalid(value): + if not value: + return True + return not re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._-]+.[a-zA-Z]{2,6}$", value) + @staticmethod def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs): readOnly = "readonly" in skelStructure[ boneName ].keys() and skelStructure[ boneName ]["readonly"] - return EmailEditBone(moduleName, boneName, readOnly) - - def unserialize(self, data): - if self.boneName in data.keys(): - self.input["value"] = data[ self.boneName ] if data[ self.boneName ] else "" + if boneName in skelStructure.keys(): + multiple = skelStructure[boneName].get("multiple", False) - def serializeForPost(self): - if not self["value"] or re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._-]+.[a-zA-Z]{2,6}$",self.input["value"]): - return( { self.boneName: self.input["value"] } ) - raise InvalidBoneValueException() + return EmailEditBone(moduleName, boneName, readOnly, multiple=multiple) def setSpecialType(self): self.input["type"]="email" diff --git a/bones/string.py b/bones/string.py index 3a460411..c9c673f3 100644 --- a/bones/string.py +++ b/bones/string.py @@ -9,7 +9,7 @@ viewDelegateSelector,\ extendedSearchWidgetSelector, \ extractorDelegateSelector - +from widgets.edit import InvalidBoneValueException class StringBoneExtractor(BaseBoneExtractor): @@ -328,6 +328,10 @@ def onBtnGenTag(self, btn): tag = self.genTag("", lang=btn.lang) tag.focus() + @staticmethod + def isInvalid(value): + return False + def unserialize(self, data, extendedErrorInformation=None): data = data.get(self.boneName) if not data: @@ -384,22 +388,34 @@ def serializeForPost(self): res["%s.%s" % (self.boneName, lang)] = [] for child in self.langEdits[lang]._children: if isinstance(child, Tag): - res["%s.%s" % (self.boneName, lang)].append(child.input["value"]) + if not self.isInvalid(child.input["value"]): + res["%s.%s" % (self.boneName, lang)].append(child.input["value"]) + else: + raise InvalidBoneValueException() elif self.languages and not self.multiple: for lang in self.languages: txt = self.langEdits[lang]["value"] if txt: - res["%s.%s" % (self.boneName, lang)] = txt + if not self.isInvalid(txt): + res["%s.%s" % (self.boneName, lang)] = txt + else: + raise InvalidBoneValueException() elif not self.languages and self.multiple: res[self.boneName] = [] for child in self.tagContainer._children: if isinstance(child, Tag): - res[self.boneName].append(child.input["value"]) + if not self.isInvalid(child.input["value"]): + res[self.boneName].append(child.input["value"]) + else: + raise InvalidBoneValueException() elif not self.languages and not self.multiple: - res[self.boneName] = self.input["value"] + if not self.isInvalid(self.input["value"]): + res[self.boneName] = self.input["value"] + else: + raise InvalidBoneValueException() return res From c3cb06beabb46dca409e52ec3f6042a253525ad2 Mon Sep 17 00:00:00 2001 From: "Andreas H. Kelch" Date: Fri, 22 Nov 2019 08:34:41 +0100 Subject: [PATCH 2/3] email fix --- bones/email.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bones/email.py b/bones/email.py index 0afef1a0..7f272018 100644 --- a/bones/email.py +++ b/bones/email.py @@ -36,7 +36,7 @@ def __init__(self, moduleName, boneName,readOnly,*args, **kwargs ): def isInvalid(value): if not value: return True - return not re.match("^[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._-]+.[a-zA-Z]{2,6}$", value) + return not re.match("^[a-zA-Z0-9._%\-+]+@[a-zA-Z0-9._\-]+.[a-zA-Z]{2,6}$", value) @staticmethod def fromSkelStructure(moduleName, boneName, skelStructure, *args, **kwargs): From 14ab2759c006f64e7195fe700deaa5d14ad42af0 Mon Sep 17 00:00:00 2001 From: phneutral Date: Wed, 18 Nov 2020 15:52:03 +0100 Subject: [PATCH 3/3] Fix for latest Chrome and Safari versions: Removed breaking overflow: hidden; in vi.less form fieldset. --- public/vi.less | 1 - 1 file changed, 1 deletion(-) diff --git a/public/vi.less b/public/vi.less index 6598f8c7..6965eefd 100644 --- a/public/vi.less +++ b/public/vi.less @@ -1238,7 +1238,6 @@ form { form fieldset { width: 100%; float: left; - overflow: hidden; color: #333; border: 0; padding: 0;