use VoteType in voting views.

This commit is contained in:
2024-05-19 10:40:41 -04:00
parent e93f37dcf0
commit 0caa41cc90
+4 -1
View File
@@ -17,7 +17,7 @@ from database_setup.sql_data_classes import (
Votes, Votes,
engine, engine,
) )
from utils import build_votes_str, get_election_name from utils import VoteType, build_votes_str, get_election_name
class VoteSelect(nextcord.ui.StringSelect): class VoteSelect(nextcord.ui.StringSelect):
@@ -47,6 +47,7 @@ class VoteSelect(nextcord.ui.StringSelect):
ElectionCycle=election_name, ElectionCycle=election_name,
VoterId=interaction.user.id, VoterId=interaction.user.id,
VotedForId=voted_for, VotedForId=voted_for,
Type=VoteType.COUNCIL,
) )
try: try:
@@ -59,6 +60,7 @@ class VoteSelect(nextcord.ui.StringSelect):
update(Votes) update(Votes)
.where(Votes.ElectionCycle == election_name) .where(Votes.ElectionCycle == election_name)
.where(Votes.VoterId == interaction.user.id) .where(Votes.VoterId == interaction.user.id)
.where(Votes.Type == VoteType.COUNCIL)
.values(VotedForId=voted_for) .values(VotedForId=voted_for)
) )
session.execute(stmt) session.execute(stmt)
@@ -121,6 +123,7 @@ class VoteView(nextcord.ui.View):
select(Votes.VotedForId) select(Votes.VotedForId)
.where(Votes.ElectionCycle == election) .where(Votes.ElectionCycle == election)
.where(Votes.VoterId == interaction.user.id) .where(Votes.VoterId == interaction.user.id)
.where(Votes.Type == VoteType.COUNCIL)
) )
voted_for = session.scalar(stmt) voted_for = session.scalar(stmt)