aboutsummaryrefslogtreecommitdiffstats
path: root/backend/routes/forms/discover.py
diff options
context:
space:
mode:
authorGravatar Joe Banks <[email protected]>2024-07-08 15:09:17 +0100
committerGravatar GitHub <[email protected]>2024-07-08 15:09:17 +0100
commit642c0795c8738bf8b9ae39b9cf0180f7cdbac650 (patch)
tree4a075255d00d9f8a2f369567bdb79f6eefa4be9a /backend/routes/forms/discover.py
parentMigration to official Sentry release CI action (#275) (diff)
parentStop using gunicorn and use uvicorn directly to run application (diff)
Merge pull request #276 from python-discord/jb3/environ/python-3.12
3.12 + Updates
Diffstat (limited to 'backend/routes/forms/discover.py')
-rw-r--r--backend/routes/forms/discover.py21
1 files changed, 7 insertions, 14 deletions
diff --git a/backend/routes/forms/discover.py b/backend/routes/forms/discover.py
index 75ff495..0fe10b5 100644
--- a/backend/routes/forms/discover.py
+++ b/backend/routes/forms/discover.py
@@ -1,6 +1,5 @@
-"""
-Return a list of all publicly discoverable forms to unauthenticated users.
-"""
+"""Return a list of all publicly discoverable forms to unauthenticated users."""
+
from spectree.response import Response
from starlette.requests import Request
from starlette.responses import JSONResponse
@@ -12,7 +11,7 @@ from backend.validation import api
__FEATURES = [
constants.FormFeatures.OPEN.value,
- constants.FormFeatures.REQUIRES_LOGIN.value
+ constants.FormFeatures.REQUIRES_LOGIN.value,
]
if not constants.PRODUCTION:
__FEATURES.append(constants.FormFeatures.DISCOVERABLE.value)
@@ -22,7 +21,7 @@ __QUESTION = Question(
name="Click the button below to log into the forms application.",
type="section",
data={"text": ""},
- required=False
+ required=False,
)
AUTH_FORM = Form(
@@ -31,14 +30,12 @@ AUTH_FORM = Form(
questions=[__QUESTION],
name="Login",
description="Log into Python Discord Forms.",
- submitted_text="This page can't be submitted."
+ submitted_text="This page can't be submitted.",
)
class DiscoverableFormsList(Route):
- """
- List all discoverable forms that should be shown on the homepage.
- """
+ """List all discoverable forms that should be shown on the homepage."""
name = "discoverable_forms_list"
path = "/discoverable"
@@ -46,15 +43,11 @@ class DiscoverableFormsList(Route):
@api.validate(resp=Response(HTTP_200=FormList), tags=["forms"])
async def get(self, request: Request) -> JSONResponse:
"""List all discoverable forms that should be shown on the homepage."""
- forms = []
cursor = request.state.db.forms.find({"features": "DISCOVERABLE"}).sort("name")
# 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(**form))
-
- forms = [form.dict(admin=False) for form in forms]
+ forms = [Form(**form).dict(admin=False) for form in await cursor.to_list(None)]
# Return an empty form in development environments to help with authentication.
if not constants.PRODUCTION: