Exemplo n.º 1
0
def add_player(request, player_id, num_days=15):
    player = get_object_or_404(Player, pk=player_id)
    delta = timedelta(days=int(num_days))
    start_day = today - delta
    player_stats = calculate_totals(player, start_day=start_day, end_day=today)
    player_avg_stats = calculate_avgs(player_stats)
    context_data['player_avg_stats'] = player_avg_stats
    context_data['player'] = player

    team = Team.objects.get(owner=request.user.id)
    team_total_stats = calculate_team_totals(team, start_day=start_day, end_day=today)
    team_avg_stats = calculate_team_avgs(team_total_stats)
    team_avg_stats.pop('totals')
    context_data['stats'] = team_avg_stats

    return render_to_response('add_player.html', context_data,
        context_instance=RequestContext(request))
Exemplo n.º 2
0
def team_profile(request, team_id, num_days=10):
    team = Team.objects.get(id=team_id)
    context_data['team'] = team

    delta = timedelta(days=int(num_days))
    start_day = today - delta
    context_data['num_days'] = num_days

    total_stats = calculate_team_totals(team,
                                        start_day=start_day,
                                        end_day=today)
    stats = calculate_team_avgs(total_stats)
    stats.pop('totals')
    context_data['stats'] = stats

    context_data['user_team'] = Team.objects.get(owner=request.user.id)

    return render_to_response("team_profile.html",
                              context_data,
                              context_instance=RequestContext(request))