Add: CouncilMembers model.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"""File holds all model definitions of SQL tables."""
|
||||
|
||||
from sqlalchemy.dialects.mysql import BIGINT, VARCHAR
|
||||
from sqlmodel import Column, Field, SQLModel
|
||||
from sqlmodel import Column, Field, ForeignKey, Relationship, SQLModel
|
||||
|
||||
|
||||
class ElectionInformation(SQLModel, table=True):
|
||||
@@ -30,3 +30,43 @@ class ElectionInformation(SQLModel, table=True):
|
||||
high_council_nomination_msg_id: int | None = Field(
|
||||
sa_column=Column("HighCouncilNominationMsgId", BIGINT(unsigned=True), nullable=True), default=None
|
||||
)
|
||||
|
||||
council_members: list["CouncilMembers"] = Relationship(back_populates="election", cascade_delete=True)
|
||||
|
||||
|
||||
class CouncilMembers(SQLModel, table=True):
|
||||
"""Represents members involved in a given election.
|
||||
|
||||
Records speech message ids for general election and high council position. Booleans record if the user was elected
|
||||
to a council/high council position.
|
||||
|
||||
Attributes:
|
||||
member_id: User that is running for council's discord id.
|
||||
speech_msg_id: Message id of user's speech.
|
||||
elected: Whether the user got elected to council.
|
||||
discord_manager: Whether the user got elected to the Discord Manager position.
|
||||
clan_leader: Whether the user got elected to the Clan Leader position.
|
||||
discord_manager_speech_id: Message id of the user's Discord Manager speech.
|
||||
clan_leader_speech_id: Message id of the user's Clan Leader speech.
|
||||
"""
|
||||
|
||||
election_name: str = Field(
|
||||
sa_column=Column(
|
||||
"ElectionName",
|
||||
VARCHAR,
|
||||
ForeignKey("ElectionInformation.ElectionName", ondelete="CASCADE"),
|
||||
primary_key=True,
|
||||
),
|
||||
max_length=30,
|
||||
)
|
||||
member_id: int = Field(sa_column=Column("MemberId", BIGINT(unsigned=True), primary_key=True, nullable=False))
|
||||
speech_msg_id: int = Field(sa_column=Column("SpeechMsgId", BIGINT(unsigned=True), nullable=False))
|
||||
elected: bool = Field(sa_column=Column("Elected"), default=False)
|
||||
discord_manager: bool = Field(sa_column=Column("DiscordManager"), default=False)
|
||||
clan_leader: bool = Field(sa_column=Column("ClanLeader"), default=False)
|
||||
discord_manager_speech_id: int = Field(
|
||||
sa_column=Column("DiscordManagerSpeechId", BIGINT(unsigned=True), nullable=True)
|
||||
)
|
||||
clan_leader_speech_id: int = Field(sa_column=Column("ClanLeaderSpeechId", BIGINT(unsigned=True), nullable=True))
|
||||
|
||||
election: ElectionInformation | None = Relationship(back_populates="council_members")
|
||||
|
||||
Reference in New Issue
Block a user