Added a BoardGamePublic class to get plays from endpoint
This commit is contained in:
parent
9778b7d314
commit
35f104cedc
2 changed files with 13 additions and 2 deletions
|
|
@ -43,6 +43,11 @@ class BoardGame(BoardGameBase, table=True):
|
||||||
type: BoardgameType = BoardgameType.BOARDGAME
|
type: BoardgameType = BoardgameType.BOARDGAME
|
||||||
plays: list["Play"] = Relationship(back_populates='boardgame')
|
plays: list["Play"] = Relationship(back_populates='boardgame')
|
||||||
|
|
||||||
|
class BoardGamePublic(BoardGameBase):
|
||||||
|
id: int
|
||||||
|
type: BoardgameType
|
||||||
|
plays: list["Play"]
|
||||||
|
|
||||||
class BoardGameNoPlays(BoardGameBase):
|
class BoardGameNoPlays(BoardGameBase):
|
||||||
id: int
|
id: int
|
||||||
type: BoardgameType = BoardgameType.BOARDGAME
|
type: BoardgameType = BoardgameType.BOARDGAME
|
||||||
|
|
@ -53,6 +58,12 @@ class BoardGameExpansion(BoardGameBase, table=True):
|
||||||
type: BoardgameType = BoardgameType.BOARDGAMEEXPANSION
|
type: BoardgameType = BoardgameType.BOARDGAMEEXPANSION
|
||||||
plays: list["Play"] = Relationship(back_populates='boardgameexpansion')
|
plays: list["Play"] = Relationship(back_populates='boardgameexpansion')
|
||||||
|
|
||||||
|
class BoardGameExpansionPublic(BoardGameBase):
|
||||||
|
id: int
|
||||||
|
expansion_for: int
|
||||||
|
type: BoardgameType
|
||||||
|
plays: list["Play"]
|
||||||
|
|
||||||
class BoardGameExpansionNoPlays(BoardGameBase):
|
class BoardGameExpansionNoPlays(BoardGameBase):
|
||||||
id: int
|
id: int
|
||||||
expansion_for: int
|
expansion_for: int
|
||||||
|
|
|
||||||
|
|
@ -99,9 +99,9 @@ def refresh():
|
||||||
return {"Status": "Already refreshing"}
|
return {"Status": "Already refreshing"}
|
||||||
|
|
||||||
|
|
||||||
@app.get("/boardgame", response_model=Union[boardgame_classes.BoardGame, boardgame_classes.BoardGameExpansion])
|
@app.get("/boardgame", response_model=Union[boardgame_classes.BoardGamePublic, boardgame_classes.BoardGameExpansionPublic])
|
||||||
def get_boardgame_by_id(id: int, session: Session = Depends(get_session)):
|
def get_boardgame_by_id(id: int, session: Session = Depends(get_session)):
|
||||||
requested_boardgame: Union[boardgame_classes.BoardGame, boardgame_classes.BoardGameExpansion] = data_connection.get_boardgame(session, id)
|
requested_boardgame = data_connection.get_boardgame(session, id)
|
||||||
return requested_boardgame
|
return requested_boardgame
|
||||||
|
|
||||||
@app.get("/owned", response_model=list[Union[boardgame_classes.OwnedBoardGame, boardgame_classes.OwnedBoardGameExpansion]])
|
@app.get("/owned", response_model=list[Union[boardgame_classes.OwnedBoardGame, boardgame_classes.OwnedBoardGameExpansion]])
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue