Created all the basic routes. Still requires some testing and cleaning
This commit is contained in:
parent
33715cb34e
commit
2ae520f6b3
3 changed files with 293 additions and 53 deletions
42
db.py
42
db.py
|
@ -9,10 +9,20 @@ class MessageBase(SQLModel):
|
|||
display_delay: int = 0
|
||||
display_repeat: int = 0
|
||||
priority: Priorities = Priorities.OVERRIDE
|
||||
sound_alarm: bool = False
|
||||
text: str = ""
|
||||
ttl: int = 0
|
||||
|
||||
|
||||
# class MessageUpdate(SQLModel):
|
||||
# activation_delay: int | None = 0
|
||||
# display_delay: int | None = 0
|
||||
# display_repeat: int | None = 0
|
||||
# priority: Priorities | None = Priorities.OVERRIDE
|
||||
# text: str | None = ""
|
||||
# ttl: int | None = 0
|
||||
|
||||
|
||||
class MessageDB(MessageBase, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
zone: "ZoneDB" = Relationship( # pyright: ignore[reportAny]
|
||||
|
@ -30,6 +40,11 @@ class NetBriteBase(SQLModel):
|
|||
port: int = 700
|
||||
|
||||
|
||||
class NetBriteUpdate(SQLModel):
|
||||
address: str = Field(unique=True, index=True)
|
||||
port: int = 700
|
||||
|
||||
|
||||
class NetBriteDB(NetBriteBase, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
zones: list["ZoneDB"] = Relationship( # pyright: ignore[reportAny]
|
||||
|
@ -46,21 +61,36 @@ class NetBritePublic(NetBriteBase):
|
|||
# --- Zone ---
|
||||
class ZoneBase(SQLModel):
|
||||
name: str
|
||||
x: int
|
||||
y: int
|
||||
width: int
|
||||
height: int
|
||||
x: int = 0
|
||||
y: int = 0
|
||||
width: int = 120
|
||||
height: int = 7
|
||||
scroll_speed: ScrollSpeeds = ScrollSpeeds.NORMAL
|
||||
pause_duration: int = 1000
|
||||
volume: int = 4
|
||||
default_font: Fonts = Fonts.NORMAL_7
|
||||
default_color: Colors = Colors.RED
|
||||
|
||||
|
||||
class ZoneUpdate(SQLModel):
|
||||
name: str | None = None
|
||||
x: int | None = None
|
||||
y: int | None = None
|
||||
width: int | None = None
|
||||
height: int | None = None
|
||||
scroll_speed: ScrollSpeeds | None = ScrollSpeeds.NORMAL
|
||||
pause_duration: int | None = 1000
|
||||
volume: int | None = 4
|
||||
default_font: Fonts | None = Fonts.NORMAL_7
|
||||
default_color: Colors | None = Colors.RED
|
||||
|
||||
|
||||
class ZoneDBBase(ZoneBase):
|
||||
default_message_id: int | None = Field(default=None, foreign_key="messagedb.id")
|
||||
netbrite_id: int = Field(default=None, foreign_key="netbritedb.id")
|
||||
|
||||
|
||||
class ZoneDB(ZoneBase, table=True):
|
||||
class ZoneDB(ZoneDBBase, table=True):
|
||||
id: int | None = Field(default=None, primary_key=True)
|
||||
|
||||
default_message: MessageDB | None = Relationship( # pyright: ignore[reportAny]
|
||||
|
@ -71,7 +101,7 @@ class ZoneDB(ZoneBase, table=True):
|
|||
)
|
||||
|
||||
|
||||
class ZonePublic(ZoneBase):
|
||||
class ZonePublic(ZoneDBBase):
|
||||
id: int
|
||||
default_message: MessagePublic
|
||||
# netbrite: NetBritePublic
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue