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

24 lines
728 B
Python
Raw Normal View History

from flask.views import MethodView
from database import Database
2023-10-03 16:25:35 +00:00
from models.requests import RequestStatus
from models.requestentry import RequestDatabaseEntry
from . import routes_requests as blp
db = Database.get_instance().db
@blp.route("/all")
class AllRequests(MethodView):
@blp.doc(summary="Returns all requests")
2023-10-03 16:25:35 +00:00
@blp.response(200, RequestDatabaseEntry(many=True), description="Successful operation")
def get(self):
db_data = db.at("requests").read()
response = []
for key, value in db_data.items():
2023-10-03 16:25:35 +00:00
value.update({
"status": RequestStatus(value["status"])
})
response.append(value)
print(response)
return response