Beispiel #1
0
def addplayer():
    if request.method == 'GET':
        last, number = [], []
        players = Players()
        last, number, player_id = players.get_players(current_user.id)
        return render_template('addplayer.html',
                               last=last,
                               player_id=player_id,
                               number=number,
                               username=str(current_user.username))
    if request.method == 'POST' and request.form.get('edit') == 'false':
        last = str(request.form.get('last'))
        number = str(request.form.get('number'))
        players = Players()
        players.add_player(last, number, current_user.id)
        first, last, number = [], [], []
        last, number, player_id = players.get_players(current_user.id)
        return render_template('addplayer.html',
                               last=last,
                               player_id=player_id,
                               number=number,
                               username=str(current_user.username))
    if request.method == 'POST' and request.form.get('edit') == 'true':
        name = str(request.form.get('name'))
        number = str(request.form.get('number'))
        player_id = str(request.form.get('id'))
        players = Players()
        players.edit_player(name, number, current_user.id, player_id)
        first, last, number = [], [], []
        last, number, player_id = players.get_players(current_user.id)
        return render_template('addplayer.html',
                               last=last,
                               player_id=player_id,
                               number=number,
                               username=str(current_user.username))
    if request.method == 'POST' and request.form.get('delete') == 'true':
        player_id = str(request.form.get('id'))
        players = Players()
        players.delete_player(player_id)
        first, last, number = [], [], []
        last, number, player_id = players.get_players(current_user.id)
        return render_template('addplayer.html',
                               last=last,
                               player_id=player_id,
                               number=number,
                               username=str(current_user.username))
Beispiel #2
0
def home(username):
    if request.method == "GET":
        games, game_id = [], []
        game_list = NewGame()
        game = Game()
        players = Players()
        last, number, player_id = players.get_players(current_user.id)
        play = Plays()
        playList, play_id = play.get_plays(current_user.id)
        total, efficient, individual, ind_used = game.data(
            current_user.id, player_id, play_id, None)
        if (len(total) != 0):
            total = total.most_common(1)[0][0]
            total = play.get_play(total)
        else:
            total = "You haven't used any plays yet."
        if (len(efficient) != 0):
            efficient = efficient.most_common(1)[0][0]
            efficient = play.get_play(efficient)
        else:
            efficient = "You haven't used any plays yet."
        if (len(individual) != 0):
            eff_player = individual.most_common(1)[0][0]
            eff_number = players.get_number(eff_player)
            player_name = players.get_player(eff_player)
            eff_player = eff_number + ' - ' + player_name
        else:
            eff_player = "You haven't used any players yet."
        if (len(ind_used) != 0):
            used_player = ind_used.most_common(1)[0][0]
            used_number = players.get_number(used_player)
            player_name = players.get_player(used_player)
            used_player = used_number + ' - ' + player_name

        else:
            used_player = "You haven't used any players yet."

        data = []
        data.append(str(total))
        data.append(str(efficient))
        data.append(str(eff_player))
        data.append(str(used_player))
        return render_template('home.html', data=data, username=username)
    elif request.method == "POST":
        if (str(request.form.get('signout')) == 'true'):
            logout_user()
            return redirect(url_for('index'))
Beispiel #3
0
def offense(game, possession):
    if request.method == "GET":
        last, number, plays, play_id, players, plays, numbers = [],[],[],[],[],[],[],
        p = Plays()
        playlist, play_id = p.get_plays(current_user.id)
        pl = Players()
        last, number, player_id = pl.get_players(current_user.id)
        gamereturn = []
        gamereturn.append(str(game))
        get_game = NewGame()
        game_id = get_game.get_game(game, current_user.id)
        g = Game()
        possessions, play_ids, player_ids, zones, results = g.game_data(
            current_user.id, game_id)
        for i in play_ids:
            plays.append(p.get_play(i))
        for i in player_ids:
            players.append(pl.get_player(i))
            numbers.append(pl.get_number(i))
        return render_template('offense.html',
                               last=last,
                               play=playlist,
                               player_id=player_id,
                               play_id=play_id,
                               player_ids=player_ids,
                               play_ids=play_ids,
                               game=gamereturn,
                               gameName=game,
                               game_id=game_id,
                               username=str(current_user.username),
                               number=number,
                               possession=possession,
                               possessions=possessions,
                               plays=plays,
                               players=players,
                               zones=zones,
                               results=results,
                               numbers=numbers)
    elif request.method == "POST" and request.form.get('edit') == 'false':
        playName = request.form.get('play')
        player = request.form.get('player')
        zone = request.form.get('zone')
        result = request.form.get('result')
        possession = request.form.get('possession')
        if possession == 'None':
            possession = '0'
        my_game = Game()
        get_game = NewGame()
        game_id = get_game.get_game(game, current_user.id)
        my_game.add_possession(str(game_id), str(possession), str(playName),
                               str(player), str(zone), str(result),
                               str(current_user.id))
        return redirect(
            url_for('offense', game=game, possession=str(int(possession) + 1)))
    elif request.method == "POST" and request.form.get('edit') == 'true':
        possession = str(request.form.get('possession'))
        possession1 = str(request.form.get('possession1'))
        play = str(request.form.get('play'))
        player = str(request.form.get('player'))
        zone = str(request.form.get('zone'))
        result = str(request.form.get('result'))
        get_game = NewGame()
        game_id = get_game.get_game(game, current_user.id)
        g = Game(game_id=game_id)
        g.edit_possession(possession, play, player, zone, result, game_id)
        return redirect(url_for('offense', game=game, possession=possession1))
Beispiel #4
0
def edit_game(game):
    if request.method == "GET":
        play, player, number = [], [], []
        g = Game()
        p = Plays()
        play_name, play_id_list = p.get_plays(current_user.id)
        pl = Players()
        player_name, player_number, player_id_list = pl.get_players(
            current_user.id)
        possession, play_id, player_id, zone, result = g.game_data(
            current_user.id, game)
        for i in play_id:
            play.append(p.get_play(i))
        for i in player_id:
            player.append(pl.get_player(i))
            number.append(pl.get_number(i))
        ng = NewGame()
        my_game = []
        game_name = ng.get_game_name(game)
        my_game.append(game_name)
        return render_template('edit_game.html',
                               game=game,
                               game_name=game_name,
                               my_game=my_game,
                               possession=possession,
                               play=play,
                               player=player,
                               zone=zone,
                               result=result,
                               play_id=play_id,
                               player_id=player_id,
                               player_name=player_name,
                               player_number=player_number,
                               player_id_list=player_id_list,
                               play_name=play_name,
                               play_id_list=play_id_list,
                               username=str(current_user.username),
                               number=number)
    if request.method == "POST" and str(request.form.get('add')) == 'false':
        possession = str(request.form.get('possession'))
        play = str(request.form.get('play'))
        player = str(request.form.get('player'))
        zone = str(request.form.get('zone'))
        result = str(request.form.get('result'))
        game = str(request.form.get('game'))
        g = Game()
        g.edit_possession(possession, play, player, zone, result, game)
        return redirect(url_for('edit_game', game=game))
    if request.method == "POST" and str(request.form.get('add')) == 'true':
        possession = str(request.form.get('possession'))
        play = str(request.form.get('play'))
        player = str(request.form.get('player'))
        zone = str(request.form.get('zone'))
        result = str(request.form.get('result'))
        g = Game()
        g.add_possession(game, possession, play, player, zone, result,
                         current_user.id)
        return redirect(url_for('edit_game', game=game))
    if request.method == "POST" and str(request.form.get('delete')) == 'true':
        game = str(request.form.get('game'))
        g = Game()
        ng = NewGame()
        g.delete_game(game)
        ng.delete_game(game)
        return redirect(url_for('games'))