aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ks129 <[email protected]>2020-12-02 14:31:25 +0200
committerGravatar ks129 <[email protected]>2020-12-02 14:31:25 +0200
commit4736125395c9103bba10c78a1e97f7f99b343745 (patch)
tree86e5cdb09602b922174b17dfda4b7ceb2ab58ea1
parentParse type and data in same validator and allow passing ID as id not _id (diff)
Fix question validator
-rw-r--r--backend/models/question.py10
1 files changed, 2 insertions, 8 deletions
diff --git a/backend/models/question.py b/backend/models/question.py
index d6b4946..1a012ff 100644
--- a/backend/models/question.py
+++ b/backend/models/question.py
@@ -36,11 +36,7 @@ class Question(BaseModel):
"""Check does required data exists for question type and remove other data."""
# When question type don't need data, don't add anything to keep DB clean.
if value.get("type") not in REQUIRED_QUESTION_TYPE_DATA:
- return {}
-
- # Required keys (and values) will be stored to here
- # to remove all unnecessary stuff
- result = {}
+ return value
for key, data_type in REQUIRED_QUESTION_TYPE_DATA[value.get("type")].items():
if key not in value.get("data", {}):
@@ -52,6 +48,4 @@ class Question(BaseModel):
f"got {type(value['data'][key]).__name__} instead."
)
- result[key] = value["data"][key]
-
- return result
+ return value