diff --git a/provisioning/cookbooks/lesswrong/templates/default/development.ini.erb b/provisioning/cookbooks/lesswrong/templates/default/development.ini.erb index 920e8d43..fdcbc951 100644 --- a/provisioning/cookbooks/lesswrong/templates/default/development.ini.erb +++ b/provisioning/cookbooks/lesswrong/templates/default/development.ini.erb @@ -146,9 +146,10 @@ about_post_id = 1 issues_post_id = 5 karma_to_post = 40 +karma_to_vote = 10 discussion_karma_to_post = 5 post_karma_multiplier = 10 -karma_to_vote = 0 +karma_to_vote_on_polls = 0 karma_to_vote_in_overview = 1000 karma_percentage_to_be_voted = 80 downvoted_reply_score_threshold = -3 diff --git a/r2/example.ini b/r2/example.ini index 85f27a24..349a6a66 100644 --- a/r2/example.ini +++ b/r2/example.ini @@ -150,8 +150,9 @@ about_post_id = 1 issues_post_id = 2 karma_to_post = 40 +karma_to_vote = 10 post_karma_multiplier = 10 -karma_to_vote = 20 +karma_to_vote_on_polls = 20 # Karma required for a user vote on another user's overview page karma_to_vote_in_overview = 1000 # User's with karma above can vote on another user's overview page if that user diff --git a/r2/r2/controllers/api.py b/r2/r2/controllers/api.py index 94bf3663..fe13e0d1 100644 --- a/r2/r2/controllers/api.py +++ b/r2/r2/controllers/api.py @@ -983,9 +983,9 @@ def POST_submitballot(self, res, comment, anonymous): if not comment: return - if c.user.safe_karma < g.karma_to_vote: + if c.user.safe_karma < g.karma_to_vote_on_polls: res._set_error(errors.BAD_POLL_BALLOT, comment._fullname, - 'You do not have the required {0} karma to vote'.format(g.karma_to_vote)) + 'You do not have the required {0} karma to vote'.format(g.karma_to_vote_on_polls)) return any_submitted = False diff --git a/r2/r2/lib/app_globals.py b/r2/r2/lib/app_globals.py index ce1f2d7b..b021fc87 100644 --- a/r2/r2/lib/app_globals.py +++ b/r2/r2/lib/app_globals.py @@ -46,13 +46,14 @@ class Globals(object): 'max_sr_images', 'karma_to_post', 'discussion_karma_to_post', - 'karma_to_vote', + 'karma_to_vote_on_polls', 'karma_to_vote_in_overview', 'karma_percentage_to_be_voted', 'meetup_grace_period', 'poll_max_choices', 'downvoted_reply_score_threshold', 'downvoted_reply_karma_cost', + 'karma_to_vote', 'hide_comment_threshold', 'side_meetups_max_age', 'side_comments_max_age', diff --git a/r2/r2/models/link.py b/r2/r2/models/link.py index 4f6069d6..abdf70ea 100644 --- a/r2/r2/models/link.py +++ b/r2/r2/models/link.py @@ -463,8 +463,11 @@ def clicked(): # Don't allow users to vote on their own posts and don't # allow users to vote on collapsed posts shown when # viewing comment permalinks. - item.votable = bool(c.user != item.author and - not getattr(item, 'for_comment_permalink', False)) + # Also require user karma to be >= global threshold as anti-sockpuppet measure + item.votable = bool(c.user_is_loggedin + and c.user != item.author + and not getattr(item, 'for_comment_permalink', False) + and c.user.safe_karma >= g.karma_to_vote) if c.user_is_loggedin and item.author._id == c.user._id: item.nofollow = False @@ -1185,7 +1188,12 @@ def add_props(cls, user, wrapped): item.can_reply = (item.sr_id in can_reply_srs) # Don't allow users to vote on their own comments - item.votable = bool(c.user != item.author and not item.retracted) + # Also require user karma to be >= global threshold as anti-sockpuppet measure + item.votable = bool(c.user_is_loggedin + and c.user != item.author + and not item.retracted + and c.user.safe_karma >= g.karma_to_vote) + if item.votable and c.profilepage: # Can only vote on profile page under certain conditions item.votable = bool((c.user.safe_karma > g.karma_to_vote_in_overview) and (g.karma_percentage_to_be_voted > item.author.percent_up())) diff --git a/r2/test.ini b/r2/test.ini index eca10bfb..a112b42c 100644 --- a/r2/test.ini +++ b/r2/test.ini @@ -145,9 +145,10 @@ about_post_id = 1 issues_post_id = 2 karma_to_post = 40 +karma_to_vote = 10 post_karma_multiplier = 10 discussion_karma_to_post = 0 -karma_to_vote = 20 +karma_to_vote_on_polls = 20 poll_max_choices = 20 downvoted_reply_score_threshold = -4