def offenders(request, bhv_id): league = get_object_or_404(League, bhv_id=bhv_id) league_offenders = logic.league_offenders(league) add_ranking_place(league_offenders, 'offender_points') return render(request, 'leagues/offenders.j2', { 'league': league, 'offenders': league_offenders, })
def scorers(request, bhv_id): league = get_object_or_404(League, bhv_id=bhv_id) players = Player.objects \ .filter(team__league=league) \ .annotate(games=Count('score')) \ .filter(games__gt=0) \ .annotate(total_goals=Coalesce(Sum('score__goals'), 0)) \ .filter(total_goals__gt=0) \ .annotate(total_penalty_goals=Sum('score__penalty_goals')) \ .annotate(total_field_goals=F('total_goals') - F('total_penalty_goals')) \ .order_by('-total_goals') add_ranking_place(players, 'total_goals') return render(request, 'leagues/scorers.html', {'league': league, 'players': players})
def scorers(request, bhv_id): team = get_object_or_404(Team, bhv_id=bhv_id) team_players = Player.objects \ .filter(team=team) \ .annotate(games=Count('score')) \ .annotate(total_goals=Coalesce(Sum('score__goals'), 0)) \ .filter(total_goals__gt=0) \ .annotate(total_penalty_goals=Sum('score__penalty_goals')) \ .annotate(total_field_goals=F('total_goals') - F('total_penalty_goals')) \ .order_by('-total_goals') add_ranking_place(team_players, 'total_goals') return render(request, 'teams/scorers.j2', { 'team': team, 'players': team_players })
def scorers(request, bhv_id): # todo: change view to show portraits and summary data of the players (not scorers data) team = get_object_or_404(Team, bhv_id=bhv_id) players = Player.objects \ .filter(team=team) \ .annotate(games=Count('score')) \ .annotate(total_goals=Coalesce(Sum('score__goals'), 0)) \ .filter(total_goals__gt=0) \ .annotate(total_penalty_goals=Sum('score__penalty_goals')) \ .annotate(total_field_goals=F('total_goals') - F('total_penalty_goals')) \ .order_by('-total_goals') add_ranking_place(players, 'total_goals') return render(request, 'teams/scorers.html', { 'team': team, 'players': players })
def penalties(request, bhv_id): league = get_object_or_404(League, bhv_id=bhv_id) players = Player.objects \ .filter(team__league=league) \ .annotate(games=Count('score')) \ .annotate(warnings=Count('score__warning_time')) \ .annotate(suspensions= Count('score__first_suspension_time') + Count('score__second_suspension_time') + Count('score__third_suspension_time')) \ .annotate(disqualifications=Count('score__disqualification_time')) \ .annotate(penalty_points=F('warnings') + 2 * F('suspensions') + 3 * F('disqualifications')) \ .filter(penalty_points__gt=0) \ .order_by('-penalty_points') add_ranking_place(players, 'penalty_points') return render(request, 'leagues/penalties.html', {'league': league, 'players': players})
def offenders(request, bhv_id): team = get_object_or_404(Team, bhv_id=bhv_id) team_offenders = Player.objects \ .filter(team=team) \ .annotate(games=Count('score')) \ .annotate(warnings=Count('score__warning_time')) \ .annotate(suspensions=Count('score__first_suspension_time') + Count('score__second_suspension_time') + Count('score__third_suspension_time')) \ .annotate(disqualifications=Count('score__disqualification_time')) \ .annotate(offender_points=F('warnings') + 2 * F('suspensions') + 3 * F('disqualifications')) \ .filter(offender_points__gt=0) \ .order_by('-offender_points') add_ranking_place(team_offenders, 'offender_points') return render(request, 'teams/offenders.j2', { 'team': team, 'offenders': team_offenders })