diff options
Diffstat (limited to 'apirouters/customize_ship.py')
-rw-r--r-- | apirouters/customize_ship.py | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/apirouters/customize_ship.py b/apirouters/customize_ship.py index c69d421..ca3ef83 100644 --- a/apirouters/customize_ship.py +++ b/apirouters/customize_ship.py @@ -2,7 +2,8 @@ from typing import Annotated from fastapi import APIRouter, Depends from pydantic import BaseModel -from .agents import auth_agent, Agent +from ..modules import ships +from ..entities.ship import Ship router = APIRouter() @@ -11,12 +12,8 @@ class RenameBody(BaseModel): name: str -# TODO depend on ship instead of auth_agent @router.post("/customize_ship/{ship_symbol}/rename") -async def rename(ship_symbol: str, rename_body: RenameBody, agent: Annotated[Agent, Depends(auth_agent)]): - for current_ship in agent.ships.values(): - if current_ship.symbol == ship_symbol: - current_ship.rename(rename_body.name) - return current_ship.get_data() +async def rename(ship_symbol: str, rename_body: RenameBody, ship: Annotated[Ship, Depends(ships.get_ship)]): + ship.rename(rename_body.name) + return ship.get_data() - return {"error": "Unknown ship symbol."} |