I was somewhat surprised to notice that user votes are not anonymous. For example if you look at my profile you'll be able to see who has voted me up or down.

I understand why some might like all votes to be public, but I think it would be useful to provide an option to make user votes anonymous.

asked 26 Jul '11, 16:49

Rich%20Seller's gravatar image

Rich Seller
1.8k154047
accept rate: 23%

edited 26 Jul '11, 16:49


I'm by no means a Python expert but I've had a go at implementing this myself. My implementation that contributes an option in the settings for anonymous votes. If unchecked (the default) user votes continue to be public. However if checked the following anonymity rules are applied:

  • Upvotes no longer show the upvoting user except to administrators and the voter.
  • Downvote details are hidden except to administrators and the voter. Other users simply see "voted down".

To implement the settings entry, I added an entry to /forum/settings/voting.py

ANONYMOUS_VOTES = Setting('ANONYMOUS_VOTES', False, VOTE_RULES_SET, dict(
label = _("Are user votes anonymous"), required=False,
help_text = _("If set to True user's votes are only visible to themselves and administrators.")))

and modified /forum/actions/meta.py, changing VoteAction.describe_vote to:

def describe_vote(self, vote_desc, viewer=None):
    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 _("%(post_desc)s") % {
            'post_desc': self.describe_node(viewer, self.node)
        }

and VoteDownAction.describe to:

def describe(self, viewer=None):
    if not settings.ANONYMOUS_VOTES or \\\\
        (viewer and viewer.is_authenticated() and viewer.is_superuser) or \\\\
        viewer == self.by or viewer == self.node.author:
        return self.describe_vote(_("voted down"), viewer)
    else:
        return _("voted down")
link

answered 26 Jul '11, 16:49

Rich%20Seller's gravatar image

Rich Seller
1.8k154047
accept rate: 23%

@Rich Seller - I notice on your own site that you haven't got anonymous voting. Did the code not work in the end?

(19 Dec '11, 19:58) Joe_Schmoe
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×144
×30
×9
×2

Asked: 26 Jul '11, 16:49

Seen: 440 times

Last updated: 19 Dec '11, 19:58

powered by OSQA