support-organizer/backend/src/routes/requests/base.py

24 lines
706 B
Python
Raw Normal View History

from flask.views import MethodView
import marshmallow as ma
from database import Database
from . import routes_requests as blp
db = Database.get_instance().db
class RequestsAll(ma.Schema):
uuid = ma.fields.String(description="UUID v4", example="3f6dd2e5-8cb1-4ce0-82e4-b68edf4ce37a")
status = ma.fields.String()
@blp.route("/all")
class AllRequests(MethodView):
@blp.doc(summary="Returns all requests")
@blp.response(200, RequestsAll(many=True), description="Successful operation")
def get(self):
db_data = db.at("requests").read()
response = []
for key, value in db_data.items():
response.append({"uuid": key, **value})
return response