github-actions[bot]
Automated Deploy: 3ea2037ab7d55d5b498f7e2ea0336818fc24f725
fe40b87
Raw History Blame Contribute Delete
1.19 kB
"""F4: send or overwrite a coach review, then notify the player."""
from typing import Annotated
from uuid import UUID
from fastapi import APIRouter, Depends, Response, status
from app.common.academy_access import CurrentStaff
from app.core.dependencies import Db, Storage
from app.integrations.push import PushClient, get_push_client
from app.modules.reviews.schemas import ReviewSubmit, ReviewSubmitted
from app.modules.reviews.service import ReviewService
router = APIRouter(prefix="/v1", tags=["reviews"])
def get_review_service(db: Db, storage: Storage,
push: Annotated[PushClient, Depends(get_push_client)]) -> ReviewService:
return ReviewService(db, storage, push)
@router.post("/sessions/{session_id}/review", status_code=status.HTTP_201_CREATED, response_model=ReviewSubmitted)
async def submit_review(session_id: UUID, body: ReviewSubmit, staff: CurrentStaff, response: Response,
service: Annotated[ReviewService, Depends(get_review_service)]) -> ReviewSubmitted:
result, created = await service.submit(staff, session_id, body)
if not created:
response.status_code = status.HTTP_200_OK
return result