def get_tables(self): tournament = self.tournament use_code_names = use_team_code_names_data_entry( self.tournament, self.tabroom) teams_table = TabbycatTableBuilder(view=self, sort_key="team", title=_("A Team")) add_link_data = [{ 'text': team_name_for_data_entry(team, use_code_names), 'link': self.get_from_team_link(team), } for team in tournament.team_set.all()] header = {'key': 'team', 'title': _("Team")} teams_table.add_column(header, add_link_data) if tournament.pref('show_team_institutions'): teams_table.add_column( { 'key': 'institution', 'icon': 'home', 'tooltip': _("Institution"), }, [ team.institution.code if team.institution else TabbycatTableBuilder.BLANK_TEXT for team in tournament.team_set.all() ]) adjudicators = tournament.adjudicator_set.all() adjs_table = TabbycatTableBuilder(view=self, sort_key="adjudicator", title=_("An Adjudicator")) adjudicators = tournament.adjudicator_set.all() add_link_data = [{ 'text': adj.name, 'link': self.get_from_adj_link(adj), } for adj in adjudicators] header = {'key': 'adjudicator', 'title': _("Adjudicator")} adjs_table.add_column(header, add_link_data) if tournament.pref('show_adjudicator_institutions'): adjs_table.add_column( { 'key': 'institution', 'icon': 'home', 'tooltip': _("Institution"), }, [ adj.institution.code if adj.institution else TabbycatTableBuilder.BLANK_TEXT for adj in adjudicators ]) return [teams_table, adjs_table]
def get_irons_list(self): iron_speeches = [] use_code_names = use_team_code_names_data_entry(self.tournament, True) for d in self._get_draw(): for side in self.tournament.sides: debateteam = d.get_dt(side) if debateteam.iron > 0 or debateteam.iron_prev: iron_speeches.append({ 'venue': d.venue.display_name if d.venue else None, 'team': team_name_for_data_entry(debateteam.team, use_code_names), 'current_round': debateteam.iron, 'previous_round': debateteam.iron_prev, }) return iron_speeches
def get_tables(self): tournament = self.tournament use_code_names = use_team_code_names_data_entry(self.tournament, self.tabroom) teams_table = TabbycatTableBuilder(view=self, sort_key="team", title=_("A Team")) add_link_data = [{ 'text': team_name_for_data_entry(team, use_code_names), 'link': self.get_from_team_link(team) } for team in tournament.team_set.all()] header = {'key': 'team', 'title': _("Team")} teams_table.add_column(header, add_link_data) if tournament.pref('show_team_institutions'): teams_table.add_column({ 'key': 'institution', 'icon': 'home', 'tooltip': _("Institution"), }, [team.institution.code if team.institution else TabbycatTableBuilder.BLANK_TEXT for team in tournament.team_set.all()]) if tournament.pref('share_adjs'): adjudicators = Adjudicator.objects.filter(Q(tournament=tournament) | Q(tournament__isnull=True)) else: adjudicators = tournament.adjudicator_set.all() adjs_table = TabbycatTableBuilder(view=self, sort_key="adjudicator", title=_("An Adjudicator")) if tournament.pref('share_adjs'): adjudicators = Adjudicator.objects.filter(Q(tournament=tournament) | Q(tournament__isnull=True)) else: adjudicators = tournament.adjudicator_set.all() add_link_data = [{ 'text': adj.name, 'link': self.get_from_adj_link(adj), } for adj in adjudicators] header = {'key': 'adjudicator', 'title': _("Adjudicator")} adjs_table.add_column(header, add_link_data) if tournament.pref('show_adjudicator_institutions'): adjs_table.add_column({ 'key': 'institution', 'icon': 'home', 'tooltip': _("Institution"), }, [adj.institution.code if adj.institution else TabbycatTableBuilder.BLANK_TEXT for adj in adjudicators]) return [teams_table, adjs_table]
def get_team_short_name(self, team): use_code_names = use_team_code_names_data_entry(self.tournament, tabroom=True) return team_name_for_data_entry(team, use_code_names)
def populate_objects(self, prefill=True): super().populate_objects() use_code_names = use_team_code_names_data_entry(self.tournament, True) self.round = self.debate.round bses = BallotSubmission.objects.filter( debate=self.debate, participant_submitter__isnull=False, discarded=False, single_adj=True, ).distinct('participant_submitter').select_related( 'participant_submitter').order_by('participant_submitter', '-version') populate_results(bses, self.tournament) self.merged_ballots = bses # Handle result conflicts self.result = DebateResult(self.ballotsub, tournament=self.tournament) try: self.result.populate_from_merge(*[b.result for b in bses]) except ResultError as e: msg, t, adj, bs, side, speaker = e.args args = { 'ballot_url': reverse_tournament(self.edit_ballot_url, self.tournament, kwargs={'pk': bs.id}), 'adjudicator': adj.name, 'speaker': speaker.name, 'team': team_name_for_data_entry(self.debate.get_team(side), use_code_names), } if t == 'speaker': msg = _( "The speaking order in the ballots is inconsistent, so could not be merged." ) elif t == 'ghost': msg = _( "Duplicate speeches are marked inconsistently, so could not be merged." ) msg += _( " This error was caught in <a href='%(ballot_url)s'>%(adjudicator)s's ballot</a> for %(speaker)s (%(team)s)." ) messages.error(self.request, msg % args) return HttpResponseRedirect(self.get_list_url()) # Handle motion conflicts bs_motions = BallotSubmission.objects.filter( id__in=[b.id for b in bses], motion__isnull=False, ).prefetch_related('debateteammotionpreference_set__debate_team') if self.tournament.pref('enable_motions'): try: merge_motions(self.ballotsub, bs_motions) except ValidationError as e: messages.error(self.request, e) return HttpResponseRedirect(self.get_list_url()) # Vetos try: self.vetos = merge_motion_vetos(self.ballotsub, bs_motions) except ValidationError as e: messages.error(self.request, e) return HttpResponseRedirect(self.get_list_url())
def get_team_short_name(self, team): use_code_names = use_team_code_names_data_entry(self.tournament, tabroom=True) return team_name_for_data_entry(team, use_code_names)