from fastapi import APIRouter from .Schemas import BaseRequest, GetTranscriptions from .Model import UserTranscriptions from App.Users.Model import User user_transcriptions_router = APIRouter(tags=["user-transcriptions"]) @user_transcriptions_router.post("/user-transcriptions/add") async def add_transcriptions(transcriptionTask: BaseRequest): user = await User.objects.filter(id=transcriptionTask.userId).first() created_task = await UserTranscriptions.objects.create( user=user, **transcriptionTask.dict() ) return {"code": 200, "message": "success", "payload": created_task.__dict__} @user_transcriptions_router.get("/user-transcriptions/all") async def get_transcriptions(user: GetTranscriptions): transcriptions = await UserTranscriptions.objects.filter(user=user.userId).all() if transcriptions == None: return { "code": 200, "message": "Success", "payload": {}, } return { "code": 200, "message": "Success", "payload": transcriptions.__dict__, }