File size: 1,189 Bytes
fe40b87
2756f0f
 
 
 
 
 
fe40b87
 
2756f0f
fe40b87
2756f0f
 
 
 
 
fe40b87
 
 
2756f0f
 
fe40b87
 
 
 
2756f0f
 
fe40b87
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""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