示例#1
0
def get_votes_from_round(user_dao, round_id, request, rnd=None):
    count = request.values.get('count', 15)
    offset = request.values.get('offset', 0)
    order_by = request.values.get('order_by', 'date')
    sort = request.values.get('sort', 'asc')
    juror_dao = JurorDAO(user_dao)
    if not rnd:
        rnd = juror_dao.get_round(round_id)
    if rnd.vote_method in ('yesno', 'rating'):
        ratings = juror_dao.get_ratings_from_round(round_id,
                                                   num=count,
                                                   offset=offset,
                                                   sort=sort,
                                                   order_by=order_by)
        data = [r.to_details_dict() for r in ratings]
    else:
        rankings = juror_dao.get_rankings_from_round(round_id)
        data = [r.to_details_dict() for r in rankings]
        data.sort(key=lambda x: x['value'])
    return {'data': data}
示例#2
0
def get_rankings_from_round(user_dao, round_id):
    juror_dao = JurorDAO(user_dao)
    rankings = juror_dao.get_rankings_from_round(round_id)
    data = [r.to_details_dict() for r in rankings]
    data.sort(key=lambda x: x['value'])
    return {'data': data}