Created Public classes
This commit is contained in:
parent
8241635e69
commit
9181f5a601
2 changed files with 34 additions and 9 deletions
|
|
@ -59,9 +59,9 @@ class BoardGame(BoardGameBase, table=True):
|
||||||
class BoardGamePublic(BoardGameBase):
|
class BoardGamePublic(BoardGameBase):
|
||||||
id: int
|
id: int
|
||||||
designers: list["DesignerPublicNoGames"]
|
designers: list["DesignerPublicNoGames"]
|
||||||
expansion_info: Optional["ExpansionInfo"]
|
expansion_info: Optional["ExpansionInfoPublicNoGame"]
|
||||||
owned_info: Optional["OwnedInfo"]
|
owned_info: Optional["OwnedInfoPublicNoGame"]
|
||||||
wishlist_info: Optional["WishlistInfo"]
|
wishlist_info: Optional["WishlistInfoPublicNoGame"]
|
||||||
|
|
||||||
|
|
||||||
class ExpansionInfo(SQLModel, table=True):
|
class ExpansionInfo(SQLModel, table=True):
|
||||||
|
|
@ -75,6 +75,13 @@ class ExpansionInfo(SQLModel, table=True):
|
||||||
back_populates="expansion_info"
|
back_populates="expansion_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class ExpansionInfoPublic(SQLModel):
|
||||||
|
expansion_for: int
|
||||||
|
boardgame: BoardGame
|
||||||
|
|
||||||
|
class ExpansionInfoPublicNoGame(SQLModel):
|
||||||
|
expansion_for: int
|
||||||
|
|
||||||
|
|
||||||
class OwnedInfo(SQLModel, table=True):
|
class OwnedInfo(SQLModel, table=True):
|
||||||
id: Optional[int] = Field(default=None, primary_key=True)
|
id: Optional[int] = Field(default=None, primary_key=True)
|
||||||
|
|
@ -89,6 +96,17 @@ class OwnedInfo(SQLModel, table=True):
|
||||||
back_populates="owned_info"
|
back_populates="owned_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class OwnedInfoPublic(SQLModel):
|
||||||
|
price_paid: float
|
||||||
|
acquisition_date: date
|
||||||
|
acquired_from: str
|
||||||
|
boardgame: BoardGame
|
||||||
|
|
||||||
|
class OwnedInfoPublicNoGame(SQLModel):
|
||||||
|
price_paid: float
|
||||||
|
acquisition_date: date
|
||||||
|
acquired_from: str
|
||||||
|
|
||||||
class WishlistInfo(SQLModel, table=True):
|
class WishlistInfo(SQLModel, table=True):
|
||||||
id: Optional[int] = Field(default=None, primary_key=True)
|
id: Optional[int] = Field(default=None, primary_key=True)
|
||||||
wishlist_priority: int
|
wishlist_priority: int
|
||||||
|
|
@ -100,6 +118,13 @@ class WishlistInfo(SQLModel, table=True):
|
||||||
back_populates="wishlist_info"
|
back_populates="wishlist_info"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
class WishlistInfoPublic(SQLModel):
|
||||||
|
wishlist_priority: int
|
||||||
|
boardgame: BoardGame
|
||||||
|
|
||||||
|
class WishlistInfoPublicNoGame(SQLModel):
|
||||||
|
wishlist_priority: int
|
||||||
|
|
||||||
|
|
||||||
# class BoardGamePublic(BoardGameBase):
|
# class BoardGamePublic(BoardGameBase):
|
||||||
# id: int
|
# id: int
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ sqlite_url = definitions.SQLITE_URL
|
||||||
|
|
||||||
|
|
||||||
connect_args = {"check_same_thread": False}
|
connect_args = {"check_same_thread": False}
|
||||||
engine = create_engine(sqlite_url, echo=False, connect_args=connect_args)
|
engine = create_engine(sqlite_url, echo=True, connect_args=connect_args)
|
||||||
|
|
||||||
def get_engine():
|
def get_engine():
|
||||||
return engine
|
return engine
|
||||||
|
|
@ -19,11 +19,11 @@ def get_engine():
|
||||||
def add_boardgame(session: Session, boardgame: boardgame_classes.BoardGame):
|
def add_boardgame(session: Session, boardgame: boardgame_classes.BoardGame):
|
||||||
|
|
||||||
with critical_function_lock:
|
with critical_function_lock:
|
||||||
# boardgame_designers = boardgame.designers
|
boardgame_designers = boardgame.designers
|
||||||
# for designer_index in range(len(boardgame_designers)):
|
for designer_index in range(len(boardgame_designers)):
|
||||||
# designer_in_db = get_designer(session, boardgame_designers[designer_index].id)
|
designer_in_db = get_designer(session, boardgame_designers[designer_index].id)
|
||||||
# if designer_in_db != None:
|
if designer_in_db != None:
|
||||||
# boardgame.designers[designer_index] = designer_in_db
|
boardgame.designers[designer_index] = designer_in_db
|
||||||
|
|
||||||
is_boardgame_present = len(session.exec(
|
is_boardgame_present = len(session.exec(
|
||||||
select(boardgame.__class__).where(boardgame.__class__.id == boardgame.id)
|
select(boardgame.__class__).where(boardgame.__class__.id == boardgame.id)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue