Move a function to utils.
This commit is contained in:
@@ -9,9 +9,7 @@ from sqlalchemy.orm import Session
|
|||||||
|
|
||||||
from config import DakinyConfig
|
from config import DakinyConfig
|
||||||
from database_setup.sql_data_classes import CouncilMembers, engine
|
from database_setup.sql_data_classes import CouncilMembers, engine
|
||||||
from utils import get_election_cycle_name
|
from utils import NOMINEE_SPLITTER, decorate_nomination, get_election_cycle_name
|
||||||
|
|
||||||
NOMINEE_SPLITTER = "========================================\n\n"
|
|
||||||
|
|
||||||
|
|
||||||
class NominateModal(nextcord.ui.Modal):
|
class NominateModal(nextcord.ui.Modal):
|
||||||
@@ -142,21 +140,3 @@ class NominateView(nextcord.ui.View):
|
|||||||
self.config, interaction.user.id, usr_nominated, speech_content
|
self.config, interaction.user.id, usr_nominated, speech_content
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def decorate_nomination(user_id: int, speech: str) -> str:
|
|
||||||
"""
|
|
||||||
Decorates a nomination speech so that it sits within multiple speeches better.
|
|
||||||
|
|
||||||
Args:
|
|
||||||
user_id (int): ID of user sending the speech
|
|
||||||
speech (str): Speech from the user
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
str: Decorated speech
|
|
||||||
"""
|
|
||||||
msg = f"**Clan Council Nominee: <@{user_id}>**\n"
|
|
||||||
msg += NOMINEE_SPLITTER
|
|
||||||
msg += speech
|
|
||||||
|
|
||||||
return msg
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ from sqlalchemy.orm import Session
|
|||||||
from config import DakinyConfig
|
from config import DakinyConfig
|
||||||
from database_setup.sql_data_classes import CouncilMembers, Votes, engine
|
from database_setup.sql_data_classes import CouncilMembers, Votes, engine
|
||||||
|
|
||||||
|
NOMINEE_SPLITTER = "========================================\n\n"
|
||||||
|
|
||||||
|
|
||||||
def get_datetime(day: str) -> datetime:
|
def get_datetime(day: str) -> datetime:
|
||||||
"""
|
"""
|
||||||
@@ -87,7 +89,9 @@ def build_votes_str(config: DakinyConfig) -> str:
|
|||||||
for nominee in session.scalars(stmt):
|
for nominee in session.scalars(stmt):
|
||||||
votes[nominee.MemberId] = 0
|
votes[nominee.MemberId] = 0
|
||||||
|
|
||||||
stmt = select(Votes).where(Votes.ElectionCycle == get_election_cycle_name(config))
|
stmt = select(Votes).where(
|
||||||
|
Votes.ElectionCycle == get_election_cycle_name(config)
|
||||||
|
)
|
||||||
|
|
||||||
for vote in session.scalars(stmt):
|
for vote in session.scalars(stmt):
|
||||||
if vote.VotedForId is not None:
|
if vote.VotedForId is not None:
|
||||||
@@ -101,3 +105,21 @@ def build_votes_str(config: DakinyConfig) -> str:
|
|||||||
votes_str += "☑️"
|
votes_str += "☑️"
|
||||||
|
|
||||||
return votes_str
|
return votes_str
|
||||||
|
|
||||||
|
|
||||||
|
def decorate_nomination(user_id: int, speech: str) -> str:
|
||||||
|
"""
|
||||||
|
Decorates a nomination speech so that it sits within multiple speeches better.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user_id (int): ID of user sending the speech
|
||||||
|
speech (str): Speech from the user
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Decorated speech
|
||||||
|
"""
|
||||||
|
msg = f"**Clan Council Nominee: <@{user_id}>**\n"
|
||||||
|
msg += NOMINEE_SPLITTER
|
||||||
|
msg += speech
|
||||||
|
|
||||||
|
return msg
|
||||||
|
|||||||
Reference in New Issue
Block a user