mirror of
https://github.com/dcs-liberation/dcs_liberation.git
synced 2025-11-10 14:22:26 +00:00
Fix FastAPI doc pages.
We can't directly use frozen dataclasses from pydcs in our interface because pydantic can't process them. Pydantic is able to automatically convert to our modelview type from the pydcs type though.
This commit is contained in:
@@ -1,16 +1,15 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from dcs.mapping import LatLng
|
||||
from pydantic.dataclasses import dataclass
|
||||
from pydantic import BaseModel
|
||||
|
||||
from game.ato import FlightWaypoint
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.server.leaflet import LeafletPoint
|
||||
|
||||
|
||||
@dataclass
|
||||
class FlightWaypointJs:
|
||||
class FlightWaypointJs(BaseModel):
|
||||
name: str
|
||||
position: LatLng
|
||||
position: LeafletPoint
|
||||
altitude_ft: float
|
||||
altitude_reference: str
|
||||
is_movable: bool
|
||||
|
||||
@@ -8,6 +8,7 @@ from game import Game
|
||||
from game.ato.flightwaypoint import FlightWaypoint
|
||||
from game.ato.flightwaypointtype import FlightWaypointType
|
||||
from game.server import GameContext
|
||||
from game.server.leaflet import LeafletPoint
|
||||
from game.server.waypoints.models import FlightWaypointJs
|
||||
from game.utils import meters
|
||||
|
||||
@@ -37,7 +38,7 @@ def all_waypoints_for_flight(
|
||||
def set_position(
|
||||
flight_id: UUID,
|
||||
waypoint_idx: int,
|
||||
position: LatLng,
|
||||
position: LeafletPoint,
|
||||
game: Game = Depends(GameContext.get),
|
||||
) -> None:
|
||||
flight = game.db.flights.get(flight_id)
|
||||
@@ -45,7 +46,9 @@ def set_position(
|
||||
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN)
|
||||
|
||||
waypoint = flight.flight_plan.waypoints[waypoint_idx - 1]
|
||||
waypoint.position = Point.from_latlng(position, game.theater.terrain)
|
||||
waypoint.position = Point.from_latlng(
|
||||
LatLng(position.lat, position.lng), game.theater.terrain
|
||||
)
|
||||
package_model = (
|
||||
GameContext.get_model()
|
||||
.ato_model_for(flight.blue)
|
||||
|
||||
Reference in New Issue
Block a user