Change ElectionCycle class to Election. Change ElectionCycle column in database to ElectionName. Update some variables for clarification.
This commit is contained in:
@@ -50,13 +50,14 @@ class NominateModal(nextcord.ui.Modal):
|
||||
|
||||
"""
|
||||
speech = decorate_nomination(interaction.user.id, self.speech.value)
|
||||
election_name = get_election_name(self.config)
|
||||
|
||||
with Session(engine) as session:
|
||||
if not self.usr_nominated:
|
||||
msg = await interaction.channel.send(speech)
|
||||
|
||||
council_member = CouncilMembers(
|
||||
ElectionCycle=get_election_name(self.config),
|
||||
ElectionName=election_name,
|
||||
MemberId=interaction.user.id,
|
||||
SpeechMsgId=msg.id,
|
||||
)
|
||||
@@ -64,10 +65,9 @@ class NominateModal(nextcord.ui.Modal):
|
||||
session.commit()
|
||||
else:
|
||||
# user already nominated, just need to update the election speech
|
||||
cycle = get_election_name(self.config)
|
||||
stmt = (
|
||||
select(CouncilMembers)
|
||||
.where(CouncilMembers.ElectionCycle == cycle)
|
||||
.where(CouncilMembers.ElectionName == election_name)
|
||||
.where(CouncilMembers.MemberId == self.usr_id)
|
||||
)
|
||||
obj = session.scalar(stmt)
|
||||
@@ -91,7 +91,7 @@ class NominateView(nextcord.ui.View):
|
||||
)
|
||||
async def nominate(self, button: nextcord.ui.Button, interaction: nextcord.Interaction) -> None: # noqa: ARG002
|
||||
"""
|
||||
Button to nominate onself for Clan Council.
|
||||
Button to nominate oneself for Clan Council.
|
||||
|
||||
Gathers previous information about the user if they have already nominated themselves, then launches
|
||||
the nomination modal to get their speech.
|
||||
@@ -108,13 +108,13 @@ class NominateView(nextcord.ui.View):
|
||||
)
|
||||
return
|
||||
|
||||
cycle = get_election_name(self.config)
|
||||
election_name = get_election_name(self.config)
|
||||
usr_nominated = False
|
||||
speech_content = ""
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
select(CouncilMembers)
|
||||
.where(CouncilMembers.ElectionCycle == cycle)
|
||||
.where(CouncilMembers.ElectionName == election_name)
|
||||
.where(CouncilMembers.MemberId == interaction.user.id)
|
||||
)
|
||||
obj = session.scalar(stmt)
|
||||
|
||||
Reference in New Issue
Block a user