Example #1
0
def process_single_tournament(session, tournament):
    tid = tournament.id

    participants = session.query(Participant).filter(
        Participant.tournament_id == tid).all()
    games = session.query(Game).filter(Game.tournament_id == tid).order_by(
        Game.id.asc()).all()

    players, decks = get_players_and_decks(session)

    args = {}
    args['admin'] = request.args.get('admin', '') == 'True'
    args['tournament'] = tournament
    args['rounds'] = helper.group_by_round(games)
    args['teams'] = get_teams_data(participants, players, decks)

    rankingManager = RankingManager()
    table = rankingManager.ranking_table(
        rankingManager.get_tournament_ranking(tid))

    args['rank_table'] = table

    return 'tournaments/single_tournament.html', args
Example #2
0
def process_thg_tournament(session, tournament):
    tid = tournament.id

    participants = session.query(Participant).filter(
        Participant.tournament_id == tid).all()
    games = session.query(Game).filter(Game.tournament_id == tid).order_by(
        Game.id.asc()).all()

    players, decks = get_players_and_decks(session)

    players_data = {}
    for p in participants:
        players_data[p.player_id] = {
            'name': players[p.player_id].name,
            'deck': decks[p.deck_id].name
        }
        players_data[p.player2_id] = {
            'name': players[p.player2_id].name,
            'deck': decks[p.deck2_id].name
        }

    args = {}
    args['admin'] = request.args.get('admin', '') == 'True'
    args['tournament'] = tournament
    args['rounds'] = helper.group_by_round(games)
    args['teams'] = get_teams_data(participants, players, decks)

    rank_manager = RankingManager()
    tournament_ranking = rank_manager.get_tournament_ranking(tid)
    table = rank_manager.ranking_table(tournament_ranking['teams'])
    players_table = rank_manager.ranking_table(tournament_ranking['players'])

    args['rank_table'] = table
    args['players_rank_table'] = players_table
    args['players'] = players_data

    return 'tournaments/thg_tournament.html', args