diff options
author | 2020-12-28 21:36:53 +0000 | |
---|---|---|
committer | 2020-12-28 21:36:53 +0000 | |
commit | 3b11fd104aac24d4b14d60babbae9afd58c8ee22 (patch) | |
tree | 67c2ca29e0a709facd18fa18cb1d7714b72f24b0 /backend/routes | |
parent | Fix deployment manifest (diff) | |
parent | Add handling of optional fields to submit endpoint (diff) |
Merge pull request #48 from python-discord/ks123/optional-questions
Diffstat (limited to 'backend/routes')
-rw-r--r-- | backend/routes/forms/submit.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/backend/routes/forms/submit.py b/backend/routes/forms/submit.py index 8588a2d..d8e6d35 100644 --- a/backend/routes/forms/submit.py +++ b/backend/routes/forms/submit.py @@ -111,7 +111,10 @@ class SubmitForm(Route): missing_fields = [] for question in form.questions: if question.id not in response["response"]: - missing_fields.append(question.id) + if not question.required: + response["response"][question.id] = None + else: + missing_fields.append(question.id) if missing_fields: return JSONResponse({ |