refactor: purge Quart from the codebase

Most functionality is still broken
This commit is contained in:
Stefan Stammberger
2021-08-27 20:54:42 +02:00
parent ede038976f
commit 3e5af8c1d1
17 changed files with 962 additions and 181 deletions
-25
View File
@@ -1,5 +1,4 @@
from cerberus import Validator # type: ignore
from quart import g, abort, jsonify, request
from functools import wraps
from http import HTTPStatus
from typing import List, Union
@@ -77,28 +76,4 @@ def check_user_exists(param: str = "usr"):
return wrap
def validate_uuids(
params: List[str], *, required: Union[bool, List[str]] = False, version: int = 4
):
def wrap(view):
@wraps(view)
async def wrapped_view(**kwargs):
query_params = {
param: request.args.get(param, type=str) for param in params
}
for param, value in query_params.items():
if not value and (required is True or (required and param in required)):
abort(HTTPStatus.BAD_REQUEST, f"`{param}` is required.")
if value:
try:
UUID(value, version=version)
except ValueError:
abort(HTTPStatus.BAD_REQUEST, f"`{param}` is not a valid UUID.")
return await view(**kwargs)
return wrapped_view
return wrap