def extra_context(request): """ This provides some extra context for the templates. """ we_live_yo = False today = datetime.date.today() league = the_league(settings.LEAGUE_ID) season = league.season_set.exclude(go_live_date__gt=today)\ .order_by('-go_live_date')[:1] if len(season) > 0: s = season[0] we_live_yo = s.go_live_date <= today and ( s.go_dead_date is None or s.go_dead_date >= today) return { 'FILER_URL': settings.FILER_URL, 'WE_LIVE_YO': we_live_yo, }
def scoreboard(request): """ Display the scoreboard. """ today = datetime.datetime.today() league = the_league(settings.LEAGUE_ID) season = league.current_season matches = [[], []] if season: divisions = league.division_set.all() rounds = (season.round_set.filter(go_dead_date__lte=today) .values_list('id', flat=True).order_by('-go_live_date')[:1]) if rounds: matches[0] = divisions[0].match_set.filter(round=rounds[0]) matches[1] = divisions[1].match_set.filter(round=rounds[0]) return { 'FIRST_DIVISION_MATCHES': matches[0], 'SECOND_DIVISION_MATCHES': matches[1], }
def standings(request): """ Display the standings """ season = the_league(settings.LEAGUE_ID).current_season return {'STANDINGS': season.get_standings() if season else []}