aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms
diff options
context:
space:
mode:
Diffstat (limited to 'backend/routes/forms')
-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..5a30a27 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."
+ })
+
await request.state.db.forms.insert_one(form.dict(by_alias=True))
return JSONResponse(form.dict())