コード例 #1
0
def team(request, manager, week=None):
    manager = manager.replace('-', ' ')
    try:
        team = Team.objects.get(manager__iexact=manager)
    except Team.DoesNotExist:
        raise Http404()

    latest_week = WeekPoints.objects.latest_week()

    if week is None:
        week = latest_week
    else:
        week = int(week)
        if not 1 <= week <= latest_week + 1:
            raise Http404()

    league = list(Team.objects.all())

    index = league.index(team)
    n = len(league)
    team_links = (league[(index - 1) % n], league[(index + 1) % n])

    week_links = (week > 1, week < latest_week + 1)

    players = team.squad.in_team(week)
    subs = team.squad.subs(week)

    for p in players:
        p.week_points = p.player.points(week)

    date_from = gameinfo.weekToDate(week)
    date_to = date_from + timedelta(days=6)

    return render(
        request, 'team.html', {
            'team': team,
            'players': players,
            'subs': subs,
            'latest_week': latest_week,
            'week': week,
            'date_from': date_from,
            'date_to': date_to,
            'week_links': week_links,
            'team_links': team_links
        })
コード例 #2
0
ファイル: views.py プロジェクト: LS80/FFL
def team(request, manager, week=None):
    manager = manager.replace('-', ' ')
    try:
        team = Team.objects.get(manager__iexact=manager)
    except Team.DoesNotExist:
        raise Http404()
    
    latest_week = WeekPoints.objects.latest_week()
    
    if week is None:
        week = latest_week
    else:
        week = int(week)
        if not 1 <= week <= latest_week + 1:
            raise Http404()
    
    league = list(Team.objects.all())

    index = league.index(team)
    n = len(league)
    team_links = (league[(index - 1) % n], league[(index + 1) % n])
    
    week_links = (week > 1, week < latest_week + 1)

    players = team.squad.in_team(week)
    subs = team.squad.subs(week)
    
    for p in players:
        p.week_points = p.player.points(week)
        
    date_from = gameinfo.weekToDate(week)
    date_to = date_from + timedelta(days=6)
    
    return render(request, 'team.html',
                  {'team': team, 'players': players, 'subs': subs, 'latest_week': latest_week,
                   'week': week, 'date_from': date_from, 'date_to': date_to,
                   'week_links': week_links, 'team_links': team_links})
コード例 #3
0
ファイル: models.py プロジェクト: LS80/FFL
 def new_players(self, week):
     return self.filter(date_added__gte=gameinfo.weekToDate(week))
コード例 #4
0
 def new_players(self, week):
     return self.filter(date_added__gte=gameinfo.weekToDate(week))