コード例 #1
0
ファイル: views.py プロジェクト: RaminNietzsche/EasyDraft
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)
コード例 #2
0
ファイル: views.py プロジェクト: rgruener/EasyDraft
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)
コード例 #3
0
ファイル: views.py プロジェクト: RaminNietzsche/EasyDraft
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)
コード例 #4
0
ファイル: views.py プロジェクト: rgruener/EasyDraft
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)
コード例 #5
0
ファイル: views.py プロジェクト: RaminNietzsche/EasyDraft
def get_team():
    league_id = request.args.get('league_id')
    team_id = request.args.get('team_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    print valid
    if not valid:
        return redirect(url_for('index'))
    team = database.get_team(team_id)
    players = database.get_team_players(team_id)
    return render_template('my_team.html', players=players, team=team)
コード例 #6
0
ファイル: views.py プロジェクト: rgruener/EasyDraft
def get_team():
    league_id = request.args.get('league_id')
    team_id = request.args.get('team_id')
    valid = database.user_in_league(current_user.get_id(), league_id)
    print valid
    if not valid:
        return redirect(url_for('index'))
    team = database.get_team(team_id)
    players = database.get_team_players(team_id)
    return render_template('my_team.html', players=players, team=team)
コード例 #7
0
ファイル: views.py プロジェクト: rgruener/EasyDraft
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)
コード例 #8
0
ファイル: views.py プロジェクト: RaminNietzsche/EasyDraft
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)
コード例 #9
0
ファイル: views.py プロジェクト: rgruener/EasyDraft
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)
コード例 #10
0
ファイル: views.py プロジェクト: RaminNietzsche/EasyDraft
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)