def get_table_by_team(self): round = self.get_round() tournament = self.get_tournament() teamscores = TeamScore.objects.filter(debate_team__debate__round=round, ballot_submission__confirmed=True).prefetch_related( 'debate_team__team__speaker_set', 'debate_team__team__institution', 'debate_team__debate__debateadjudicator_set__adjudicator') debates = [ts.debate_team.debate for ts in teamscores] populate_opponents([ts.debate_team for ts in teamscores]) for pos in [DebateTeam.POSITION_AFFIRMATIVE, DebateTeam.POSITION_NEGATIVE]: debates_for_pos = [ts.debate_team.debate for ts in teamscores if ts.debate_team.position == pos] populate_confirmed_ballots(debates_for_pos, motions=True) table = TabbycatTableBuilder(view=self, sort_key="Team") table.add_team_columns([ts.debate_team.team for ts in teamscores]) table.add_debate_result_by_team_columns(teamscores) table.add_debate_ballot_link_column(debates) table.add_debate_adjudicators_column(debates, show_splits=True) if tournament.pref('show_motions_in_results'): table.add_motion_column([debate.confirmed_ballot.motion if debate.confirmed_ballot else None for debate in debates]) return table
def get_table(self): """On team record pages, the table is the results table.""" tournament = self.get_tournament() teamscores = TeamScore.objects.filter(debate_team__team=self.object, ballot_submission__confirmed=True, debate_team__debate__round__seq__lt=tournament.current_round.seq, debate_team__debate__round__draw_status=Round.STATUS_RELEASED, debate_team__debate__round__silent=False).select_related( 'debate_team__debate', 'debate_team__debate__round').prefetch_related( 'debate_team__debate__debateadjudicator_set__adjudicator') debates = [ts.debate_team.debate for ts in teamscores] populate_opponents([ts.debate_team for ts in teamscores]) populate_confirmed_ballots(debates, motions=True, ballotsets=True) table = TabbycatTableBuilder(view=self, title="Results", sort_key="Round") table.add_round_column([debate.round for debate in debates]) table.add_debate_result_by_team_columns(teamscores) table.add_debate_adjudicators_column(debates, show_splits=True) if self.admin or tournament.pref('public_motions'): table.add_motion_column([debate.confirmed_ballot.motion if debate.confirmed_ballot else None for debate in debates]) table.add_debate_ballot_link_column(debates) return table
def get_table(self): """On team record pages, the table is the results table.""" tournament = self.get_tournament() teamscores = TeamScore.objects.filter( debate_team__team=self.object, ballot_submission__confirmed=True, debate_team__debate__round__draw_status=Round.STATUS_RELEASED ).select_related('debate_team__debate__round').prefetch_related( Prefetch('debate_team__debate__debateadjudicator_set', queryset=DebateAdjudicator.objects.select_related( 'adjudicator__institution')), 'debate_team__debate__debateteam_set') if not tournament.pref('all_results_released'): teamscores = teamscores.filter( debate_team__debate__round__silent=False, debate_team__debate__round__seq__lt=tournament.current_round. seq) debates = [ts.debate_team.debate for ts in teamscores] populate_opponents([ts.debate_team for ts in teamscores]) populate_confirmed_ballots(debates, motions=True, ballotsets=True) table = TabbycatTableBuilder(view=self, title="Results", sort_key="Round") table.add_round_column([debate.round for debate in debates]) table.add_debate_result_by_team_columns(teamscores) table.add_debate_adjudicators_column(debates, show_splits=True) if self.admin or tournament.pref('public_motions'): table.add_motion_column([ debate.confirmed_ballot.motion if debate.confirmed_ballot else None for debate in debates ]) table.add_debate_ballot_link_column(debates) return table