feat: begin to add support for multiple teams

This commit is contained in:
2025-03-19 15:08:18 +01:00
parent c246a0b264
commit ded2b79db7
7 changed files with 91 additions and 42 deletions

15
main.py
View File

@@ -59,14 +59,15 @@ def add_players(players: list[Player]):
session.commit()
async def list_players():
async def list_players(team_id: int):
with Session(engine) as session:
statement = select(Player).order_by(Player.display_name)
players = session.exec(statement).fetchall()
return [
player.model_dump(include={"id", "display_name", "number"})
for player in players
]
statement = select(Team).where(Team.id == team_id)
players = [t.players for t in session.exec(statement)][0]
if players:
return [
player.model_dump(include={"id", "display_name", "number"})
for player in players
]
async def read_teams_me(user: Annotated[Player, Depends(get_current_active_user)]):