Permalink
Browse files

OSQA-820: Configurable anonymous voting

Code from meta.osqa.net, but doesn't treat down votes differently:
http://meta.osqa.net/questions/9683/should-it-be-possible-to-make-user-votes-anonymous
  • Loading branch information...
1 parent 2c8cf2e commit b2a30f131701a2e7a7749fda0e247d94e039054a @DanielThomas committed Mar 1, 2012
Showing with 14 additions and 5 deletions.
  1. +9 −4 forum/actions/meta.py
  2. +5 −1 forum/settings/voting.py
View
@@ -36,10 +36,15 @@ def get_action_for(cls, user, node):
return None
def describe_vote(self, vote_desc, viewer=None):
- return _("%(user)s %(vote_desc)s %(post_desc)s") % {
- 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
- 'vote_desc': vote_desc, 'post_desc': self.describe_node(viewer, self.node)
- }
+ if not settings.ANONYMOUS_VOTES or (viewer and viewer.is_authenticated() and viewer.is_superuser):
+ return _("%(user)s %(vote_desc)s %(post_desc)s") % {
+ 'user': self.hyperlink(self.user.get_profile_url(), self.friendly_username(viewer, self.user)),
+ 'vote_desc': vote_desc, 'post_desc': self.describe_node(viewer, self.node)
+ }
+ else:
+ return _("%(vote_desc)s %(post_desc)s") % {
+ 'vote_desc': vote_desc, 'post_desc': self.describe_node(viewer, self.node)
+ }
class VoteUpAction(VoteAction):
View
@@ -3,6 +3,10 @@
VOTE_RULES_SET = SettingSet('voting', _('Voting rules'), _("Configure the voting rules on your site."), 400)
+ANONYMOUS_VOTES = Setting('ANONYMOUS_VOTES', False, VOTE_RULES_SET, dict(
+label = _("User votes anonymous"), required=False,
+help_text = _("If set to True user's votes are only visible to themselves and administrators.")))
+
USER_REPUTATION_TO_MAX_VOTES = Setting('USER_REPUTATION_TO_MAX_VOTES', True, VOTE_RULES_SET, dict(
label = _("Add reputation to max votes per day"), required=False,
help_text = _("The user reputation is added to the static MAX_VOTES_PER_DAY option. Users with higher reputation can vote more.")))
@@ -29,4 +33,4 @@
DENY_UNVOTE_DAYS = Setting('DENY_UNVOTE_DAYS', 1, VOTE_RULES_SET, dict(
label = _("Days to cancel a vote"),
-help_text = _("How many days an user can cancel a vote after he originaly casted it.")))
+help_text = _("How many days an user can cancel a vote after he originaly casted it.")))

0 comments on commit b2a30f1

Please sign in to comment.