aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms/new.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2020-12-12 14:33:37 +0000
committerGravatar GitHub <[email protected]>2020-12-12 14:33:37 +0000
commit558b99282ddf742104c62519817954791beb605a (patch)
treecfa3b6e6a57de4278027e254385ddc759496b2b9 /backend/routes/forms/new.py
parentAdd name and description fields to Form model (diff)
parentMerge pull request #17 from python-discord/ks123/response-model-endpoint (diff)
Merge branch 'main' into ks123/form-name-description
Diffstat (limited to 'backend/routes/forms/new.py')
-rw-r--r--backend/routes/forms/new.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/backend/routes/forms/new.py b/backend/routes/forms/new.py
index ff39f12..6437a4a 100644
--- a/backend/routes/forms/new.py
+++ b/backend/routes/forms/new.py
@@ -26,5 +26,10 @@ class FormCreate(Route):
except ValidationError as e:
return JSONResponse(e.errors())
+ if await request.state.db.forms.find_one({"_id": form.id}):
+ return JSONResponse({
+ "error": "Form with same ID already exists."
+ }, status_code=400)
+
await request.state.db.forms.insert_one(form.dict(by_alias=True))
return JSONResponse(form.dict())