Ejemplo n.º 1
0
def fetch_group(request):
    group = Group.objects.get(week=request.GET.get('week'),
                              group=request.GET.get('group'))

    tables = [game.table for game in group.games.distinct('table')]
    matches = []
    for table in tables:
        games = [{
            'id': game.id,
            'player': {
                'id': game.player.id,
                'name': game.player.name
            },
            'score': game.score,
            'league_points': game.league_points
        } for game in group.games.filter(table=table)]
        matches.append({
            'games': games,
            'table': {
                'id': table.id,
                'name': table.name
            }
        })
    model = {'matches': matches}
    model['tables'] = [
        basic_json(table) for table in Table.objects.filter(status='Active')
    ]
    model['players'] = [basic_json(player) for player in group.players.all()]
    model['week'] = group.week
    model['group'] = group.group
    return json_response(model)
Ejemplo n.º 2
0
def fetch_group(request):
    group = Group.objects.get(week=request.GET.get('week'), group=request.GET.get('group'))

    tables = [game.table for game in group.games.distinct('table')]
    matches = []
    for table in tables:
        games = [{'id': game.id, 'player': {'id': game.player.id, 'name': game.player.name}, 'score': game.score, 'league_points': game.league_points} for game in group.games.filter(table=table)]
        matches.append({'games': games, 'table': {'id': table.id, 'name': table.name}})
    model = {'matches': matches}
    model['tables'] = [basic_json(table) for table in Table.objects.filter(status='Active')]
    model['players'] = [basic_json(player) for player in group.players.all()]
    model['week'] = group.week
    model['group'] = group.group
    return json_response(model)
Ejemplo n.º 3
0
def fetch_tables(request):
    tables = [basic_json(table) for table in Table.objects.filter(status='Active')]
    return json_response(tables)
Ejemplo n.º 4
0
def fetch_players(request):
    players = [basic_json(player) for player in Player.objects.all()]
    return json_response(players)
Ejemplo n.º 5
0
def fetch_tables(request):
    tables = [
        basic_json(table) for table in Table.objects.filter(status='Active')
    ]
    return json_response(tables)
Ejemplo n.º 6
0
def fetch_players(request):
    players = [basic_json(player) for player in Player.objects.all()]
    return json_response(players)