Ejemplo n.º 1
0
def draft_success():
    league_id = request.args.get('league_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    if not valid:
        return redirect(url_for('index'))
    league = database.get_league(league_id)
    return render_template('draft_success.html', league=league)
Ejemplo n.º 2
0
def draft_success():
    league_id = request.args.get('league_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    if not valid:
        return redirect(url_for('index'))
    league = database.get_league(league_id)
    return render_template('draft_success.html', league=league)
Ejemplo n.º 3
0
def get_league():
    league_id = request.args.get('league_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    if not valid:
        return redirect(url_for('index'))
    league = database.get_league(league_id)
    teams = database.get_league_teams(league_id)
    return render_template('league.html', league=league, teams=teams)
Ejemplo n.º 4
0
def get_league():
    league_id = request.args.get('league_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    if not valid:
        return redirect(url_for('index'))
    league = database.get_league(league_id)
    teams = database.get_league_teams(league_id)
    return render_template('league.html', league=league, teams=teams)
Ejemplo n.º 5
0
def draft_day():
    draft = dict()
    draft['league_id'] = request.args.get('league_id')
    draft['time'] = request.args.get('time')
    draft['order'] = request.args.get('order')
    draft['selection'] = request.args.get('selection')
    valid = database.user_in_league(current_user.get_id(), draft['league_id'])
    if not valid or not draft['league_id'] or not draft['time']:
        return redirect(url_for('index'))
    teams = database.get_league_teams(draft['league_id'])
    draft['current_team'] = int(request.args.get('current_team') or 0)
    draft['direction'] = int(request.args.get('direction') or 1)
    print teams, draft['current_team'], draft['direction']
    if request.args.get('pick') != '0' and request.args.get(
            'pick') is not None:
        print "Made Pick"
        pick_id = request.args.get('pick')
        database.insert_pick(teams[draft['current_team']][0], pick_id)
        num_picks = database.get_total_draft(draft['league_id'])[0]
        total_picks = int(database.get_league(
            draft['league_id'])[2]) * len(teams)
        print num_picks, total_picks
        if num_picks >= total_picks:
            database.complete_draft(draft['league_id'])
            return redirect(
                url_for('draft_success', league_id=draft['league_id']))
        if draft['current_team'] == len(teams) - 1 and draft['direction'] == 1:
            draft['direction'] = draft['direction'] * -1
        elif draft['current_team'] == 0 and draft['direction'] == -1:
            draft['direction'] = draft['direction'] * -1
        else:
            draft['current_team'] = draft['current_team'] + draft['direction']
    position = request.args.get('position')
    nfl_team = request.args.get('nfl_team')
    player_name = request.args.get('player')
    order_by = request.args.get('sort')
    limit = request.args.get('max_return')
    if not order_by:
        order_by = 'last_name'
    if not limit:
        limit = '200'
    players = database.get_players_draft(draft['league_id'],
                                         order_by=order_by,
                                         position=position,
                                         nfl_team=nfl_team,
                                         last_name=player_name,
                                         limit=limit)
    team_players = database.get_team_players(teams[draft['current_team']][0])
    search = DraftSearchForm()
    return render_template("draft_day.html",
                           draft=draft,
                           players=players,
                           search=search,
                           team=teams[draft['current_team']],
                           team_players=team_players)
Ejemplo n.º 6
0
def draft_setup():
    league_id = request.args.get('league_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    if not valid:
        return redirect(url_for('index'))
    form = DraftSetupForm()
    league = database.get_league(league_id)
    if request.method =='POST' and form.validate():
        return redirect(url_for('draft_day', time=form.draft_time.data, league_id=league_id, \
                order=form.draft_order.data, selection=form.draft_positions.data))
    return render_template("draft_setup.html", form=form, league=league)
Ejemplo n.º 7
0
def draft_setup():
    league_id = request.args.get('league_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    if not valid:
        return redirect(url_for('index'))
    form = DraftSetupForm()
    league = database.get_league(league_id)
    if request.method == 'POST' and form.validate():
        return redirect(url_for('draft_day', time=form.draft_time.data, league_id=league_id, \
                order=form.draft_order.data, selection=form.draft_positions.data))
    return render_template("draft_setup.html", form=form, league=league)
Ejemplo n.º 8
0
def draft_day():
    draft = dict()
    draft['league_id'] = request.args.get('league_id')
    draft['time'] = request.args.get('time')
    draft['order'] = request.args.get('order')
    draft['selection'] = request.args.get('selection')
    valid = database.user_in_league(current_user.get_id(), draft['league_id'])
    if not valid or not draft['league_id'] or not draft['time']:
        return redirect(url_for('index'))
    teams = database.get_league_teams(draft['league_id'])
    draft['current_team'] = int(request.args.get('current_team') or 0)
    draft['direction'] = int(request.args.get('direction') or 1)
    print teams, draft['current_team'], draft['direction']
    if request.args.get('pick') != '0' and request.args.get('pick') is not None:
        print "Made Pick"
        pick_id = request.args.get('pick')
        database.insert_pick(teams[draft['current_team']][0], pick_id)
        num_picks = database.get_total_draft(draft['league_id'])[0]
        total_picks = int(database.get_league(draft['league_id'])[2]) * len(teams)
        print num_picks, total_picks
        if num_picks >= total_picks:
            database.complete_draft(draft['league_id'])
            return redirect(url_for('draft_success', league_id=draft['league_id']))
        if draft['current_team'] == len(teams)-1 and draft['direction'] == 1:
            draft['direction'] = draft['direction'] * -1
        elif draft['current_team'] == 0 and draft['direction'] == -1:
            draft['direction'] = draft['direction'] * -1
        else:
            draft['current_team'] = draft['current_team'] + draft['direction']
    position = request.args.get('position')
    nfl_team = request.args.get('nfl_team')
    player_name = request.args.get('player')
    order_by = request.args.get('sort')
    limit = request.args.get('max_return')
    if not order_by:
        order_by = 'last_name'
    if not limit:
        limit = '200'
    players = database.get_players_draft(draft['league_id'], order_by=order_by, position=position, nfl_team=nfl_team, last_name=player_name, limit=limit)
    team_players = database.get_team_players(teams[draft['current_team']][0])
    search = DraftSearchForm()
    return render_template("draft_day.html", draft=draft, players=players, search=search, team=teams[draft['current_team']], team_players=team_players)