예제 #1
0
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)
예제 #2
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)
예제 #3
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)
예제 #4
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)