#11 Identity checks for voting.
Closed: Fixed None Opened 15 years ago by nigelj.

I'm not sure how or even IF we can implement this nicely, BUT:

We need to check that users are in a group marked as eligible for voting (i.e. in the legalvoters table).

Toshio, I've set this to you, have you got any ideas? Feel free to bounce it back to me though :)


Yep. We should be able to do this with turbogears identity.

Something like:

{{{
@identity.require(identity.not_anonymous())
def vote_controller_method(self):
# In production, we'd get this from the database
legalGroups = ('list', 'of', 'groupnames', 'that', 'can', 'vote')
if [True for group in legalGroups if group in identity.current.groups ]:
# return a dict with a message that the user can't vote in this election
return
# Process the vote.
}}}

http://docs.turbogears.org/1.0/UsingIdentity

[changeset:25/trunk/elections/controllers.py Done in r25] not technically the way suggested, but it works, should be improved for 0.2.0 but seems okay.

Login to comment on this ticket.

Metadata