diff options
Diffstat (limited to 'backend/routes/forms/discover.py')
-rw-r--r-- | backend/routes/forms/discover.py | 21 |
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: |