2023-10-01 17:47:35 +00:00
|
|
|
from flask.views import MethodView
|
|
|
|
|
2023-11-24 19:50:18 +00:00
|
|
|
from ...database import Database
|
|
|
|
from ...models.requests import RequestStatus
|
|
|
|
from ...models.requestentry import RequestDatabaseEntry
|
2023-10-01 17:47:35 +00:00
|
|
|
from . import routes_requests as blp
|
|
|
|
|
2023-10-01 19:40:06 +00:00
|
|
|
db = Database.get_instance().db
|
|
|
|
|
2023-10-01 17:47:35 +00:00
|
|
|
@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")
|
2023-10-01 17:47:35 +00:00
|
|
|
def get(self):
|
2023-10-01 19:40:06 +00:00
|
|
|
db_data = db.at("requests").read()
|
|
|
|
response = []
|
2023-10-03 16:31:52 +00:00
|
|
|
for value in db_data.values():
|
2023-10-03 16:25:35 +00:00
|
|
|
value.update({
|
|
|
|
"status": RequestStatus(value["status"])
|
|
|
|
})
|
|
|
|
response.append(value)
|
|
|
|
print(response)
|
2023-10-01 17:47:35 +00:00
|
|
|
return response
|