Skip to content

Commit

Permalink
Backport 3.7 code to 3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
phorward committed Dec 18, 2024
1 parent 538c52a commit 416eb3a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

This file documents any relevant changes done to ViUR-core since version 3.

## [3.6.30]

- fix: `SelectBone.singleValueFromClient` doesn't accept `Enum` (#1320, #1351)

## [3.6.29]

- fix: Don't create a CSP nonce if unsafe-inline is enabled (#1347)
Expand Down
15 changes: 10 additions & 5 deletions src/viur/core/bones/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,23 @@ def singleValueSerialize(self, val, skel: 'SkeletonInstance', name: str, parentI
return val

def singleValueFromClient(self, value, skel, bone_name, client_data):
if isinstance(value, enum.Enum):
value = value.value
if isinstance(self._values, enum.EnumMeta) and isinstance(value, self._values):
return value, None

if not str(value):
value = str(value)
if not value:
return self.getEmptyValue(), [ReadFromClientError(ReadFromClientErrorSeverity.Empty, "No value selected")]

for key in self.values.keys():
if str(key) == str(value):
if str(key) == value:
if isinstance(self._values, enum.EnumMeta):
return self._values(key), None

return key, None

return self.getEmptyValue(), [
ReadFromClientError(ReadFromClientErrorSeverity.Invalid, "Invalid value selected")]
ReadFromClientError(ReadFromClientErrorSeverity.Invalid, "Invalid value selected")
]

def structure(self) -> dict:
return super().structure() | {
Expand Down
2 changes: 1 addition & 1 deletion src/viur/core/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# This will mark it as a pre-release as well on PyPI.
# See CONTRIBUTING.md for further information.

__version__ = "3.6.29"
__version__ = "3.6.30"

assert __version__.count(".") >= 2 and "".join(__version__.split(".", 3)[:3]).isdigit(), \
"Semantic __version__ expected!"

0 comments on commit 416eb3a

Please sign in to comment.