Major refactor WIP

This commit is contained in:
2026-04-03 11:13:44 -04:00
parent dee58e0aae
commit 7b2de645db
25 changed files with 5841 additions and 7760 deletions
+38
View File
@@ -6,6 +6,11 @@ from app.models.circuit import Circuit
from app.schemas.circuit import CircuitCreate, CircuitUpdate
from app.models.journal import EntityType
from app.crud.crud_journal import journal
from app.crud.crud_movement import movement as movement_crud
from app.schemas.movement import MovementCreate
from app.models.movement import MovementType
from app.crud.crud_local_flight import local_flight as crud_local_flight
from app.crud.crud_arrival import arrival as crud_arrival
class CRUDCircuit:
@@ -56,6 +61,39 @@ class CRUDCircuit:
user_ip
)
# Create TOUCH_AND_GO movement
if obj_in.local_flight_id:
flight = crud_local_flight.get(db, obj_in.local_flight_id)
if flight:
movement_data = MovementCreate(
movement_type=MovementType.TOUCH_AND_GO,
aircraft_registration=flight.registration,
aircraft_type=flight.type,
callsign=flight.callsign,
timestamp=obj_in.circuit_timestamp,
entity_type="LOCAL_FLIGHT",
entity_id=obj_in.local_flight_id,
created_by=user,
ip_address=user_ip
)
movement_crud.create(db, movement_data)
elif obj_in.arrival_id:
arrival = crud_arrival.get(db, obj_in.arrival_id)
if arrival:
movement_data = MovementCreate(
movement_type=MovementType.TOUCH_AND_GO,
aircraft_registration=arrival.registration,
aircraft_type=arrival.type,
callsign=arrival.callsign,
timestamp=obj_in.circuit_timestamp,
entity_type="ARRIVAL",
entity_id=obj_in.arrival_id,
from_location=arrival.in_from,
created_by=user,
ip_address=user_ip
)
movement_crud.create(db, movement_data)
return db_obj
def update(self, db: Session, db_obj: Circuit, obj_in: CircuitUpdate, user: str = "system", user_ip: Optional[str] = None) -> Circuit: