1+
12from fastapi import APIRouter , Depends , HTTPException
23from sqlalchemy .orm import Session
34
4- from app .schemas .time_block import TimeBlockBase
5- from app .schemas .suggested_times import SuggestedTimeCreateRequest , SuggestedTimeEntity
6- from app .services .implementations .suggested_times_service import SuggestedTimesService
7- from app .utilities .db_utils import get_db
8-
9- from typing import List
10-
11-
5+ from app .middleware .auth import has_roles
126from app .schemas .suggested_times import (
137 SuggestedTimeCreateRequest ,
14- SuggestedTimeGetRequest ,
15- SuggestedTimeDeleteRequest ,
168 SuggestedTimeCreateResponse ,
9+ SuggestedTimeDeleteRequest ,
10+ SuggestedTimeDeleteResponse ,
11+ SuggestedTimeGetRequest ,
1712 SuggestedTimeGetResponse ,
18- SuggestedTimeDeleteResponse
1913)
20- from app .middleware .auth import has_roles
2114from app .schemas .user import UserRole
15+ from app .services .implementations .suggested_times_service import SuggestedTimesService
16+ from app .utilities .db_utils import get_db
2217
2318router = APIRouter (
2419 prefix = "/suggested-times" ,
@@ -31,12 +26,12 @@ def get_suggested_times_service(db: Session = Depends(get_db)):
3126@router .post ("/" , response_model = SuggestedTimeCreateResponse )
3227async def create_suggested_times (
3328 suggested_time : SuggestedTimeCreateRequest ,
34- suggested_time_service : SuggestedTimesService = Depends (get_suggested_times_service ),
29+ time_service : SuggestedTimesService = Depends (get_suggested_times_service ),
3530 authorized : bool = has_roles ([UserRole .ADMIN , UserRole .PARTICIPANT ]),
3631):
3732 try :
38- created_suggested_time = await suggested_time_service .create_suggested_time (suggested_time )
39- return created_suggested_time
33+ created = await time_service .create_suggested_time (suggested_time )
34+ return created
4035 except HTTPException as http_ex :
4136 raise http_ex
4237 except Exception as e :
@@ -46,12 +41,12 @@ async def create_suggested_times(
4641@router .get ("/" , response_model = SuggestedTimeGetResponse )
4742async def get_suggested_times (
4843 match_id : int ,
49- suggested_time_service : SuggestedTimesService = Depends (get_suggested_times_service ),
44+ time_service : SuggestedTimesService = Depends (get_suggested_times_service ),
5045 authorized : bool = has_roles ([UserRole .ADMIN , UserRole .VOLUNTEER ]),
5146):
5247 try :
5348 req = SuggestedTimeGetRequest (match_id = match_id )
54- suggested_times = suggested_time_service .get_suggested_time_by_match_id (req )
49+ suggested_times = time_service .get_suggested_time_by_match_id (req )
5550 return suggested_times
5651 except HTTPException as http_ex :
5752 raise http_ex
@@ -62,13 +57,13 @@ async def get_suggested_times(
6257@router .delete ("/" , response_model = SuggestedTimeDeleteResponse )
6358async def delete_suggested_times (
6459 match_id : int ,
65- suggested_time_service : SuggestedTimesService = Depends (get_suggested_times_service ),
60+ time_service : SuggestedTimesService = Depends (get_suggested_times_service ),
6661 authorized : bool = has_roles ([UserRole .ADMIN , UserRole .VOLUNTEER ]),
6762):
6863 try :
6964 req = SuggestedTimeDeleteRequest (match_id = match_id )
70- deleted_suggested_time = await suggested_time_service .delete_suggested_times_by_match_id (req )
71- return deleted_suggested_time
65+ deleted = await time_service .delete_suggested_times_by_match_id (req )
66+ return deleted
7267 except HTTPException as http_ex :
7368 raise http_ex
7469 except Exception as e :
0 commit comments