Many more states WIP
This commit is contained in:
@@ -26,7 +26,17 @@ class CRUDLocalFlight:
|
||||
query = db.query(LocalFlight)
|
||||
|
||||
if status:
|
||||
query = query.filter(LocalFlight.status == status)
|
||||
if status == LocalFlightStatus.CIRCUIT:
|
||||
# Special case: when requesting CIRCUIT status, return all circuit-related statuses
|
||||
circuit_statuses = [
|
||||
LocalFlightStatus.CIRCUIT,
|
||||
LocalFlightStatus.CIRCUIT_DOWNWIND,
|
||||
LocalFlightStatus.CIRCUIT_BASE,
|
||||
LocalFlightStatus.CIRCUIT_FINAL
|
||||
]
|
||||
query = query.filter(LocalFlight.status.in_(circuit_statuses))
|
||||
else:
|
||||
query = query.filter(LocalFlight.status == status)
|
||||
|
||||
if flight_type:
|
||||
query = query.filter(LocalFlight.flight_type == flight_type)
|
||||
@@ -74,11 +84,20 @@ class CRUDLocalFlight:
|
||||
)
|
||||
).order_by(LocalFlight.created_dt).all()
|
||||
|
||||
def create(self, db: Session, obj_in: LocalFlightCreate, created_by: str) -> LocalFlight:
|
||||
def create(self, db: Session, obj_in: LocalFlightCreate, created_by: str, submitted_via: str = "ADMIN") -> LocalFlight:
|
||||
from app.models.local_flight import SubmissionSource
|
||||
|
||||
# Set initial status based on submission source
|
||||
initial_status = LocalFlightStatus.BOOKED_OUT
|
||||
|
||||
if submitted_via == SubmissionSource.ADMIN:
|
||||
initial_status = LocalFlightStatus.GROUND
|
||||
|
||||
db_obj = LocalFlight(
|
||||
**obj_in.dict(),
|
||||
created_by=created_by,
|
||||
status=LocalFlightStatus.BOOKED_OUT
|
||||
status=initial_status,
|
||||
submitted_via=submitted_via
|
||||
)
|
||||
db.add(db_obj)
|
||||
db.commit()
|
||||
|
||||
Reference in New Issue
Block a user