Skip to content

Commit 71e4eff

Browse files
committed
new feature: translation of settings in models
1 parent b24b1b7 commit 71e4eff

File tree

4 files changed

+35
-10
lines changed

4 files changed

+35
-10
lines changed

.github/workflows/release.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ jobs:
1212
os: [ubuntu-latest, windows-latest]
1313
python-version: ["3.9", "3.10", "3.11", "3.12"]
1414
steps:
15-
- uses: actions/checkout@v2
15+
- uses: actions/checkout@v4
1616

1717
- name: Set up Python
18-
uses: actions/setup-python@v1
18+
uses: actions/setup-python@v4
1919
with:
2020
python-version: ${{ matrix.python-version }}
2121

@@ -26,7 +26,7 @@ jobs:
2626
2727
- name: Build wheels on Ubuntu
2828
if: matrix.os == 'ubuntu-latest'
29-
uses: RalfG/python-wheels-manylinux-build@v0.5.0-manylinux2014_x86_64
29+
uses: RalfG/python-wheels-manylinux-build@v0.7.1-manylinux2014_x86_64
3030
with:
3131
python-versions: 'cp39-cp39 cp310-cp310 cp311-cp311 cp312-cp312'
3232
build-requirements: 'cython numpy'
@@ -39,7 +39,7 @@ jobs:
3939
# You may need to adjust the above command based on your package's specific requirements
4040
4141
- name: Upload wheel artifacts
42-
uses: actions/upload-artifact@v2
42+
uses: actions/upload-artifact@v4
4343
with:
4444
name: wheels-${{ matrix.os }}-py${{ matrix.python-version }}
4545
path: dist/*.whl
@@ -48,10 +48,10 @@ jobs:
4848
needs: build
4949
runs-on: ubuntu-latest
5050
steps:
51-
- uses: actions/checkout@v2
51+
- uses: actions/checkout@v4
5252

5353
- name: Download all artifacts
54-
uses: actions/download-artifact@v2
54+
uses: actions/download-artifact@v4.1.7
5555
with:
5656
path: dist
5757

@@ -76,7 +76,7 @@ jobs:
7676
run: ls -l dist
7777

7878
- name: Set up Python
79-
uses: actions/setup-python@v1
79+
uses: actions/setup-python@v4
8080
with:
8181
python-version: '3.x'
8282

datamodel/base.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,26 @@ def _get_meta_value(self, key: str, fallback: Any = None, locale: Any = None):
455455
value = locale(value)
456456
return value
457457

458+
def _get_meta_values(
459+
self,
460+
key: dict,
461+
fallback: Any = None,
462+
locale: Any = None
463+
):
464+
"""
465+
_get_meta_values.
466+
467+
Translates the entire dictionary of Meta values.
468+
"""
469+
values = getattr(self.Meta, key, fallback)
470+
if locale is not None:
471+
for key, val in values.items():
472+
try:
473+
values[key] = locale(val)
474+
except (KeyError, TypeError):
475+
pass
476+
return values
477+
458478
def _get_metadata(self, field, key: str, locale: Any = None):
459479
value = field.metadata.get(key, None)
460480
if locale is not None:
@@ -520,11 +540,11 @@ def schema(cls, as_dict=False, locale: Any = None):
520540
defs = {}
521541

522542
# settings:
523-
settings = cls._get_meta_value(
543+
settings = cls._get_meta_values(
524544
cls,
525545
'settings',
526546
fallback={},
527-
locale=None
547+
locale=locale
528548
)
529549
try:
530550
settings = {

datamodel/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
__title__ = 'python-datamodel'
55
__description__ = ('simple library based on python +3.8 to use Dataclass-syntax'
66
'for interacting with Data')
7-
__version__ = '0.7.0'
7+
__version__ = '0.7.1'
88
__author__ = 'Jesus Lara'
99
__author_email__ = '[email protected]'
1010
__license__ = 'BSD'

examples/json_schema.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ class Meta:
3939
description: str = 'airports'
4040
title: str = 'airports'
4141
schema = 'public'
42+
settings = {
43+
"showSubmit": True,
44+
"SubmitLabel": "submit",
45+
"showCancel": False
46+
}
4247
strict = True
4348

4449
localization = 'it_IT'

0 commit comments

Comments
 (0)