diff options
author | 2020-12-02 15:24:15 +0200 | |
---|---|---|
committer | 2020-12-02 15:24:15 +0200 | |
commit | dbe8d21a826311a4ab9fa08f9d9b73def128c7fc (patch) | |
tree | 11fd1424efccbd39a0281a626d02ae6eaccb98d7 | |
parent | Fix question validator (diff) |
Move data to Form and then back to dictionary for id converting
-rw-r--r-- | backend/routes/forms/discover.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/backend/routes/forms/discover.py b/backend/routes/forms/discover.py index f16faa4..af6066e 100644 --- a/backend/routes/forms/discover.py +++ b/backend/routes/forms/discover.py @@ -4,6 +4,7 @@ Return a list of all publicly discoverable forms to unauthenticated users. from starlette.requests import Request from starlette.responses import JSONResponse +from backend.models import Form from backend.route import Route @@ -19,8 +20,12 @@ class DiscoverableFormsList(Route): forms = [] cursor = request.state.db.forms.find({"features": "DISCOVERABLE"}) + # Parse it to Form and then back to dictionary + # to replace _id with id for form in await cursor.to_list(None): - forms.append(form) + forms.append(Form(**form)) + + forms = [form.dict() for form in forms] return JSONResponse( forms |