Skip to content
This repository has been archived by the owner on Apr 17, 2018. It is now read-only.

require a minimum user karma to upvote and downvote #558

Merged
merged 3 commits into from
Feb 18, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ downvoted_reply_score_threshold = -3
downvoted_reply_karma_cost = 5
hide_comment_threshold = -4

# If user's karma is less than threshold, thing.votable = False
# meaning that the voting icons won't appear on posts and comments
# "karma_to_vote" is only used for voting in polls.
no_voting_threshold = 10

side_meetups_max_age = 60
side_comments_max_age = 60
side_posts_max_age = 300
Expand Down
5 changes: 5 additions & 0 deletions r2/example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,11 @@ karma_to_vote_in_overview = 1000
karma_percentage_to_be_voted = 80
poll_max_choices = 20

# If user's karma is less than threshold, thing.votable = False
# meaning that the voting icons won't appear on posts and comments
# "karma_to_vote" is only used for voting in polls.
no_voting_threshold = 10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this setting should be renamed to remove the negative no and be clearer about what the value is. The best way to do this may be to rename karma_to_vote to karma_to_vote_on_polls and make this setting karma_to_vote.


downvoted_reply_score_threshold = -4
downvoted_reply_karma_cost = 5
hide_comment_threshold = -4
Expand Down
1 change: 1 addition & 0 deletions r2/r2/lib/app_globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Globals(object):
'poll_max_choices',
'downvoted_reply_score_threshold',
'downvoted_reply_karma_cost',
'no_voting_threshold',
'hide_comment_threshold',
'side_meetups_max_age',
'side_comments_max_age',
Expand Down
14 changes: 11 additions & 3 deletions r2/r2/models/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.no_voting_threshold)

if c.user_is_loggedin and item.author._id == c.user._id:
item.nofollow = False
Expand Down Expand Up @@ -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.no_voting_threshold)

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()))
Expand Down
5 changes: 5 additions & 0 deletions r2/test.ini
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,11 @@ discussion_karma_to_post = 0
karma_to_vote = 20
poll_max_choices = 20

# If user's karma is less than threshold, thing.votable = False
# meaning that the voting icons won't appear on posts and comments
# "karma_to_vote" is only used for voting in polls.
no_voting_threshold = 10

downvoted_reply_score_threshold = -4
downvoted_reply_karma_cost = 5
hide_comment_threshold = -4
Expand Down