Skip to content
This repository was archived by the owner on Jan 24, 2024. It is now read-only.

Commit e14a84e

Browse files
committed
Fix cumulative poll
1 parent 928b8f8 commit e14a84e

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

pollbot/telegram/callback_handler/vote.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -174,25 +174,25 @@ def handle_cumulative_vote(session, context, option, unlimited=False):
174174
allowed_votes = option.poll.number_of_votes
175175

176176
# Upvote, but no votes left
177-
if not unlimited and action == CallbackResult.vote_yes and vote_count >= allowed_votes:
177+
if not unlimited and action == CallbackResult.yes and vote_count >= allowed_votes:
178178
respond_to_vote(session, 'No votes left!', context, option.poll)
179179
return False
180180

181181
# Early return if downvote on non existing vote
182-
if existing_vote is None and action == CallbackResult.vote_no:
182+
if existing_vote is None and action == CallbackResult.no:
183183
respond_to_vote(session, 'Cannot downvote this option.', context, option.poll)
184184
return False
185185

186186
if existing_vote:
187187
# Add to an existing vote
188-
if action == CallbackResult.vote_yes:
188+
if action == CallbackResult.yes:
189189
existing_vote.vote_count += 1
190190
session.commit()
191191
total_vote_count = allowed_votes - (vote_count + 1)
192192
respond_to_vote(session, f'Vote added!', context, option.poll, total_vote_count, True)
193193

194194
# Remove from existing vote
195-
elif action == CallbackResult.vote_no:
195+
elif action == CallbackResult.no:
196196
existing_vote.vote_count -= 1
197197
session.commit()
198198
total_vote_count = allowed_votes - (vote_count - 1)
@@ -204,7 +204,7 @@ def handle_cumulative_vote(session, context, option, unlimited=False):
204204
session.commit()
205205

206206
# Add new vote
207-
elif existing_vote is None and action == CallbackResult.vote_yes:
207+
elif existing_vote is None and action == CallbackResult.yes:
208208
vote = Vote(context.user, option)
209209
session.add(vote)
210210
session.commit()

pollbot/telegram/keyboard/vote.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ def get_normal_buttons(poll):
6767
def get_cumulative_buttons(poll):
6868
"""Get the cumulative keyboard with two buttons per option."""
6969
vote_button_type = CallbackType.vote.value
70-
vote_yes = CallbackResult.vote_yes.value
71-
vote_no = CallbackResult.vote_no.value
70+
vote_yes = CallbackResult.yes.value
71+
vote_no = CallbackResult.no.value
7272

7373
options = poll.options
7474
if poll.option_sorting == OptionSorting.option_name:

0 commit comments

Comments
 (0)