Skip to content
Snippets Groups Projects
Commit e889d410 authored by Erwan Rouchet's avatar Erwan Rouchet
Browse files

Merge branch 'bool-user-conf' into 'master'

Allow booleans as subtype for list parameters in user configuration

Closes #1349

See merge request teklia/arkindex/backend!1809
parents b402b315 433fc152
No related branches found
No related tags found
1 merge request!1809Allow booleans as subtype for list parameters in user configuration
...@@ -110,8 +110,8 @@ class UserConfigurationFieldSerializer(serializers.Serializer): ...@@ -110,8 +110,8 @@ class UserConfigurationFieldSerializer(serializers.Serializer):
if subtype is not None: if subtype is not None:
if field_type != UserConfigurationFieldType.List: if field_type != UserConfigurationFieldType.List:
errors['subtype'].append('The "subtype" field can only be set for a "list" type property.') errors['subtype'].append('The "subtype" field can only be set for a "list" type property.')
if subtype not in [UserConfigurationFieldType.Int, UserConfigurationFieldType.Float, UserConfigurationFieldType.String]: if subtype not in [UserConfigurationFieldType.Int, UserConfigurationFieldType.Float, UserConfigurationFieldType.String, UserConfigurationFieldType.Boolean]:
errors['subtype'].append('Subtype can only be int, float or string.') errors['subtype'].append('Subtype can only be int, float, bool or string.')
# Handle enums # Handle enums
if choices is not None: if choices is not None:
if field_type != UserConfigurationFieldType.Enum: if field_type != UserConfigurationFieldType.Enum:
......
...@@ -842,6 +842,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): ...@@ -842,6 +842,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
"configuration": { "configuration": {
"user_configuration": { "user_configuration": {
"demo_list": {"title": "Demo List", "type": "list", "required": True, "subtype": "int", "default": [1, 2, 3, 4]}, "demo_list": {"title": "Demo List", "type": "list", "required": True, "subtype": "int", "default": [1, 2, 3, 4]},
"boolean_list": {"title": "It's a list of booleans", "type": "list", "required": False, "subtype": "bool", "default": [True, False, False]}
} }
}, },
"gpu_usage": "disabled", "gpu_usage": "disabled",
...@@ -857,6 +858,13 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): ...@@ -857,6 +858,13 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
"subtype": "int", "subtype": "int",
"required": True, "required": True,
"default": [1, 2, 3, 4] "default": [1, 2, 3, 4]
},
"boolean_list": {
"title": "It's a list of booleans",
"type": "list",
"subtype": "bool",
"required": False,
"default": [True, False, False]
} }
} }
}) })
...@@ -934,7 +942,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase): ...@@ -934,7 +942,7 @@ class TestWorkersWorkerVersions(FixtureAPITestCase):
"configuration": { "configuration": {
"user_configuration": [{ "user_configuration": [{
"demo_list": { "demo_list": {
"subtype": ["Subtype can only be int, float or string."] "subtype": ["Subtype can only be int, float, bool or string."]
} }
}] }]
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment