def vote(r, **attr):
    '\n        Custom Method to allow Voting on Solutions to a Problem\n    '
    problem = r.record
    duser = s3db.delphi_DelphiUser(problem.group_id)
    rheader = problem_rheader(r)
    stable = s3db.delphi_solution
    query = (stable.problem_id == problem.id)
    rows = db(query).select(stable.id, stable.name)
    options = Storage()
    for row in rows:
        options[row.id] = row.name
    if duser.user_id:
        vtable = s3db.delphi_vote
        query = ((vtable.problem_id == problem.id) & (vtable.created_by == auth.user.id))
        votes = db(query).select(vtable.solution_id, orderby=vtable.rank)
    else:
        votes = []
    rankings = OrderedDict()
    for v in votes:
        rankings[v.solution_id] = options[v.solution_id]
        options.pop(v.solution_id)
    s3.stylesheets.append('S3/delphi.css')
    js = ''.join(('var problem_id=', str(problem.id), '\ni18n.delphi_failed="', str(T('Failed!')), '"\ni18n.delphi_saving="', str(T('Saving...')), '"\ni18n.delphi_saved="', str(T('Saved.')), '"\ni18n.delphi_vote="', str(T('Save Vote')), '"'))
    s3.js_global.append(js)
    s3.scripts.append(URL(c='static', f='scripts', args=['S3', 's3.delphi.js']))
    response.view = 'delphi/vote.html'
    return dict(rheader=rheader, duser=duser, votes=votes, options=options, rankings=rankings)
Custom Method to allow Voting on Solutions to a Problem
def vote(r, **attr):
    '\n        \n    '
    problem = r.record
    duser = s3db.delphi_DelphiUser(problem.group_id)
    rheader = problem_rheader(r)
    stable = s3db.delphi_solution
    query = (stable.problem_id == problem.id)
    rows = db(query).select(stable.id, stable.name)
    options = Storage()
    for row in rows:
        options[row.id] = row.name
    if duser.user_id:
        vtable = s3db.delphi_vote
        query = ((vtable.problem_id == problem.id) & (vtable.created_by == auth.user.id))
        votes = db(query).select(vtable.solution_id, orderby=vtable.rank)
    else:
        votes = []
    rankings = OrderedDict()
    for v in votes:
        rankings[v.solution_id] = options[v.solution_id]
        options.pop(v.solution_id)
    s3.stylesheets.append('S3/delphi.css')
    js = .join(('var problem_id=', str(problem.id), '\ni18n.delphi_failed="', str(T('Failed!')), '"\ni18n.delphi_saving="', str(T('Saving...')), '"\ni18n.delphi_saved="', str(T('Saved.')), '"\ni18n.delphi_vote="', str(T('Save Vote')), '"'))
    s3.js_global.append(js)
    s3.scripts.append(URL(c='static', f='scripts', args=['S3', 's3.delphi.js']))
    response.view = 'delphi/vote.html'
    return dict(rheader=rheader, duser=duser, votes=votes, options=options, rankings=rankings)