Remove config param from get_election_name().
This commit is contained in:
+7
-7
@@ -162,7 +162,7 @@ class Election:
|
|||||||
"""Performs required actions for when the election cycle starts."""
|
"""Performs required actions for when the election cycle starts."""
|
||||||
# create new channel for election
|
# create new channel for election
|
||||||
parent: nextcord.TextChannel = self.guild.get_channel(settings.channel_ids.voting_parent)
|
parent: nextcord.TextChannel = self.guild.get_channel(settings.channel_ids.voting_parent)
|
||||||
quarter_name: str = get_election_name(settings)
|
quarter_name: str = get_election_name()
|
||||||
|
|
||||||
thread_msg: nextcord.Message = await parent.send(content=quarter_name)
|
thread_msg: nextcord.Message = await parent.send(content=quarter_name)
|
||||||
|
|
||||||
@@ -205,7 +205,7 @@ class Election:
|
|||||||
)
|
)
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(ElectionInformation).where(ElectionInformation.ElectionName == get_election_name(settings))
|
stmt = select(ElectionInformation).where(ElectionInformation.ElectionName == get_election_name())
|
||||||
info = session.scalar(stmt)
|
info = session.scalar(stmt)
|
||||||
info.CouncilVoteMsgId = vote_msg.id
|
info.CouncilVoteMsgId = vote_msg.id
|
||||||
session.commit()
|
session.commit()
|
||||||
@@ -222,7 +222,7 @@ class Election:
|
|||||||
|
|
||||||
nominate_msg: nextcord.Message = await election_thread.send(message, view=NominateHighCouncilView(self.guild))
|
nominate_msg: nextcord.Message = await election_thread.send(message, view=NominateHighCouncilView(self.guild))
|
||||||
|
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
# remove vote button from vote message
|
# remove vote button from vote message
|
||||||
@@ -272,7 +272,7 @@ class Election:
|
|||||||
)
|
)
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(ElectionInformation).where(ElectionInformation.ElectionName == get_election_name(settings))
|
stmt = select(ElectionInformation).where(ElectionInformation.ElectionName == get_election_name())
|
||||||
info = session.scalar(stmt)
|
info = session.scalar(stmt)
|
||||||
info.HighCouncilVoteMsgId = vote_msg.id
|
info.HighCouncilVoteMsgId = vote_msg.id
|
||||||
session.commit()
|
session.commit()
|
||||||
@@ -288,7 +288,7 @@ class Election:
|
|||||||
elect_role: nextcord.Role = self.guild.get_role(settings.role_ids.clan_council_elect)
|
elect_role: nextcord.Role = self.guild.get_role(settings.role_ids.clan_council_elect)
|
||||||
council_role: nextcord.Role = self.guild.get_role(settings.role_ids.clan_council)
|
council_role: nextcord.Role = self.guild.get_role(settings.role_ids.clan_council)
|
||||||
|
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
# role management
|
# role management
|
||||||
@@ -353,7 +353,7 @@ class Election:
|
|||||||
|
|
||||||
# clear view from vote message
|
# clear view from vote message
|
||||||
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
||||||
ElectionInformation.ElectionName == get_election_name(settings)
|
ElectionInformation.ElectionName == get_election_name()
|
||||||
)
|
)
|
||||||
vote_msg_id = session.scalar(stmt)
|
vote_msg_id = session.scalar(stmt)
|
||||||
vote_msg: nextcord.Message = await election_thread.fetch_message(vote_msg_id)
|
vote_msg: nextcord.Message = await election_thread.fetch_message(vote_msg_id)
|
||||||
@@ -376,7 +376,7 @@ class Election:
|
|||||||
ElectionInformation: The information from the database about the current election.
|
ElectionInformation: The information from the database about the current election.
|
||||||
"""
|
"""
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(ElectionInformation).where(ElectionInformation.ElectionName == get_election_name(settings))
|
stmt = select(ElectionInformation).where(ElectionInformation.ElectionName == get_election_name())
|
||||||
return session.scalar(stmt)
|
return session.scalar(stmt)
|
||||||
|
|
||||||
async def election_reminder(self) -> None:
|
async def election_reminder(self) -> None:
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ class NominateDMModal(nextcord.ui.Modal):
|
|||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
# user already in table
|
# user already in table
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
stmt = (
|
stmt = (
|
||||||
select(CouncilMembers)
|
select(CouncilMembers)
|
||||||
.where(CouncilMembers.ElectionName == election_name)
|
.where(CouncilMembers.ElectionName == election_name)
|
||||||
@@ -116,7 +116,7 @@ class NominateCLModal(nextcord.ui.Modal):
|
|||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
# user already in table
|
# user already in table
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
stmt = (
|
stmt = (
|
||||||
select(CouncilMembers)
|
select(CouncilMembers)
|
||||||
.where(CouncilMembers.ElectionName == election_name)
|
.where(CouncilMembers.ElectionName == election_name)
|
||||||
@@ -165,7 +165,7 @@ class NominateHighCouncilView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
usr_nominated = False
|
usr_nominated = False
|
||||||
speech_content = ""
|
speech_content = ""
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
@@ -208,7 +208,7 @@ class NominateHighCouncilView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
usr_nominated = False
|
usr_nominated = False
|
||||||
speech_content = ""
|
speech_content = ""
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class NominateModal(nextcord.ui.Modal):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
speech = decorate_nomination(interaction.user.id, self.speech.value)
|
speech = decorate_nomination(interaction.user.id, self.speech.value)
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
if not self.usr_nominated:
|
if not self.usr_nominated:
|
||||||
@@ -105,7 +105,7 @@ class NominateView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
usr_nominated = False
|
usr_nominated = False
|
||||||
speech_content = ""
|
speech_content = ""
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
|||||||
Args:
|
Args:
|
||||||
interaction (Interaction): Interaction with this callback.
|
interaction (Interaction): Interaction with this callback.
|
||||||
"""
|
"""
|
||||||
election_name: str = get_election_name(settings)
|
election_name: str = get_election_name()
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
||||||
ElectionInformation.ElectionName == election_name
|
ElectionInformation.ElectionName == election_name
|
||||||
@@ -111,7 +111,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
election_name: str = get_election_name(settings)
|
election_name: str = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = (
|
stmt = (
|
||||||
@@ -183,7 +183,7 @@ class VoteHighcouncilView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
election_name: str = get_election_name(settings)
|
election_name: str = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = (
|
stmt = (
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
|||||||
Args:
|
Args:
|
||||||
interaction (Interaction): Interaction with this callback.
|
interaction (Interaction): Interaction with this callback.
|
||||||
"""
|
"""
|
||||||
election_name = get_election_name(settings)
|
election_name = get_election_name()
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(ElectionInformation.CouncilVoteMsgId).where(ElectionInformation.ElectionName == election_name)
|
stmt = select(ElectionInformation.CouncilVoteMsgId).where(ElectionInformation.ElectionName == election_name)
|
||||||
vote_msg_id = session.scalar(stmt)
|
vote_msg_id = session.scalar(stmt)
|
||||||
@@ -102,7 +102,7 @@ class VoteView(nextcord.ui.View):
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
election_name: str = get_election_name(settings)
|
election_name: str = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = (
|
stmt = (
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import nextcord
|
|||||||
from sqlalchemy import select, true, update
|
from sqlalchemy import select, true, update
|
||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from DakinySettings import DakinySettings
|
from DakinySettings import settings
|
||||||
from database_setup.sql_data_classes import (
|
from database_setup.sql_data_classes import (
|
||||||
CouncilMembers,
|
CouncilMembers,
|
||||||
EventPoints,
|
EventPoints,
|
||||||
@@ -57,18 +57,15 @@ def get_datetime(day: str) -> datetime:
|
|||||||
return datetime(year, month, day, tzinfo=UTC)
|
return datetime(year, month, day, tzinfo=UTC)
|
||||||
|
|
||||||
|
|
||||||
def get_election_name(config: DakinySettings) -> str:
|
def get_election_name() -> str:
|
||||||
"""
|
"""
|
||||||
Builds the unique name of the current election cycle.
|
Builds the unique name of the current election cycle.
|
||||||
|
|
||||||
Args:
|
|
||||||
config (DakinyConfig): the config used to know the election cycle.
|
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
str: the name of the election cycle
|
str: the name of the election cycle
|
||||||
"""
|
"""
|
||||||
cycle = get_current_election_cycle(config)
|
cycle = get_current_election_cycle(settings)
|
||||||
current_cycle = config.election_cycles[cycle]
|
current_cycle = settings.election_cycles[cycle]
|
||||||
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
|
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
|
||||||
|
|
||||||
|
|
||||||
@@ -145,7 +142,7 @@ def build_votes_str(config: DakinySettings, guild: nextcord.Guild) -> str:
|
|||||||
"""
|
"""
|
||||||
votes: dict[int, int] = {}
|
votes: dict[int, int] = {}
|
||||||
|
|
||||||
election_name = get_election_name(config)
|
election_name = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = select(CouncilMembers).where(CouncilMembers.ElectionName == election_name)
|
stmt = select(CouncilMembers).where(CouncilMembers.ElectionName == election_name)
|
||||||
@@ -182,7 +179,7 @@ def build_highcouncil_votes_str(config: DakinySettings, guild: nextcord.Guild) -
|
|||||||
cl_votes: dict[int, int] = {}
|
cl_votes: dict[int, int] = {}
|
||||||
dm_votes: dict[int, int] = {}
|
dm_votes: dict[int, int] = {}
|
||||||
|
|
||||||
election_name = get_election_name(config)
|
election_name = get_election_name()
|
||||||
|
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = (
|
stmt = (
|
||||||
@@ -512,7 +509,7 @@ async def edit_clan_council_info(guild: nextcord.Guild, config: DakinySettings)
|
|||||||
"""
|
"""
|
||||||
clan_info_channel: nextcord.TextChannel = await guild.fetch_channel(config.params.clan_info_channel_id)
|
clan_info_channel: nextcord.TextChannel = await guild.fetch_channel(config.params.clan_info_channel_id)
|
||||||
|
|
||||||
election_name = get_election_name(config)
|
election_name = get_election_name()
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
stmt = (
|
stmt = (
|
||||||
select(CouncilMembers.MemberId)
|
select(CouncilMembers.MemberId)
|
||||||
|
|||||||
Reference in New Issue
Block a user