Check if a post is archived before attempting to vote on it
This commit is contained in:
1 parent
b164b5a6ba
commit
542c660b67
4 files changed
+2485
-1
No files matched your search
@@ -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()
|
||||
|
||||
Reference in new issue
Block a user