Before refactor

This commit is contained in:
2026-03-24 13:35:29 -04:00
parent bb6597ff76
commit eb2321ef40
10 changed files with 208 additions and 75 deletions
+24 -1
View File
@@ -33,6 +33,17 @@ async def get_circuits_by_flight(
return circuits
@router.get("/arrival/{arrival_id}", response_model=List[Circuit])
async def get_circuits_by_arrival(
arrival_id: int,
db: Session = Depends(get_db),
current_user: User = Depends(get_current_read_user)
):
"""Get all circuits for a specific arrival"""
circuits = crud_circuit.get_by_arrival(db, arrival_id=arrival_id)
return circuits
@router.post("/", response_model=Circuit)
async def create_circuit(
request: Request,
@@ -40,7 +51,19 @@ async def create_circuit(
db: Session = Depends(get_db),
current_user: User = Depends(get_current_operator_user)
):
"""Record a new circuit (touch and go) for a local flight"""
"""Record a new circuit (touch and go) for a local flight or arrival"""
# Validate that exactly one of local_flight_id or arrival_id is provided
if not circuit_in.local_flight_id and not circuit_in.arrival_id:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Either local_flight_id or arrival_id must be provided"
)
if circuit_in.local_flight_id and circuit_in.arrival_id:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="Cannot provide both local_flight_id and arrival_id"
)
circuit = crud_circuit.create(db, obj_in=circuit_in)
# Send real-time update via WebSocket