Check if a post is archived before attempting to vote on it

This commit is contained in:
Michael Lazar
2018-08-05 00:32:11 -04:00
parent b164b5a6ba
commit 542c660b67
4 changed files with 2485 additions and 1 deletions

View File

@@ -163,6 +163,8 @@ class Page(object):
data = self.get_selected_item()
if 'likes' not in data:
self.term.flash()
elif getattr(data['object'], 'archived'):
self.term.show_notification("Voting disabled for archived post", style='Error')
elif data['likes']:
with self.term.loader('Clearing vote'):
data['object'].clear_vote()
@@ -180,6 +182,8 @@ class Page(object):
data = self.get_selected_item()
if 'likes' not in data:
self.term.flash()
elif getattr(data['object'], 'archived'):
self.term.show_notification("Voting disabled for archived post", style='Error')
elif data['likes'] or data['likes'] is None:
with self.term.loader('Voting'):
data['object'].downvote()