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)
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)
def fetch_tables(request): tables = [basic_json(table) for table in Table.objects.filter(status='Active')] return json_response(tables)
def fetch_players(request): players = [basic_json(player) for player in Player.objects.all()] return json_response(players)
def fetch_tables(request): tables = [ basic_json(table) for table in Table.objects.filter(status='Active') ] return json_response(tables)