コード例 #1
0
    def get_draw(self):
        round = self.get_round()

        # The use-case for prefetches here is so intense that we'll just implement
        # a separate one (as opposed to use Round.debate_set_with_prefetches())
        draw = round.debate_set.select_related(
            'round__tournament').prefetch_related(
                Prefetch('debateadjudicator_set',
                         queryset=DebateAdjudicator.objects.select_related(
                             'adjudicator__institution__region')),
                Prefetch(
                    'debateteam_set',
                    queryset=DebateTeam.objects.select_related(
                        'team__institution__region').prefetch_related(
                            Prefetch(
                                'team__speaker_set',
                                queryset=Speaker.objects.order_by('name')), )),
                'debateteam_set__team__break_categories',
            )
        populate_win_counts(
            [dt.team for debate in draw for dt in debate.debateteam_set.all()])
        populate_feedback_scores([
            da.adjudicator for debate in draw
            for da in debate.debateadjudicator_set.all()
        ])

        serialised_draw = [d.serialize() for d in draw]
        draw = self.annotate_draw(draw, serialised_draw)
        return json.dumps(serialised_draw)
コード例 #2
0
ファイル: views.py プロジェクト: czlee/tabbycat
 def get_unallocated_adjudicators(self):
     round = self.round
     unused_adj_instances = round.unused_adjudicators().select_related('institution__region')
     populate_feedback_scores(unused_adj_instances)
     unused_adjs = [a.serialize(round) for a in unused_adj_instances]
     unused_adjs = [self.annotate_region_classes(a) for a in unused_adjs]
     unused_adjs = [self.annotate_conflicts(a, 'for_adjs') for a in unused_adjs]
     return json.dumps(unused_adjs)
コード例 #3
0
 def get_serialised_allocatable_items(self):
     adjs = Adjudicator.objects.filter(tournament=self.tournament)
     adjs = annotate_availability(adjs, self.round)
     populate_feedback_scores(adjs)
     weight = self.tournament.current_round.feedback_weight
     serialized_adjs = EditPanelOrDebateAdjSerializer(
         adjs, many=True, context={'feedback_weight': weight})
     return self.json_render(serialized_adjs.data)
コード例 #4
0
ファイル: views.py プロジェクト: jacksison/jujmpa
 def get_unallocated_adjudicators(self):
     round = self.round
     unused_adj_instances = round.unused_adjudicators().select_related('institution__region')
     populate_feedback_scores(unused_adj_instances)
     unused_adjs = [a.serialize(round) for a in unused_adj_instances]
     unused_adjs = [self.annotate_region_classes(a) for a in unused_adjs]
     unused_adjs = [self.annotate_conflicts(a, 'for_adjs') for a in unused_adjs]
     return json.dumps(unused_adjs)
コード例 #5
0
 def get_adjudicators(self):
     if not hasattr(self, '_adjudicators'):
         t = self.tournament
         if t.pref('share_adjs'):
             self._adjudicators = Adjudicator.objects.filter(Q(tournament=t) | Q(tournament__isnull=True))
         else:
             self._adjudicators = Adjudicator.objects.filter(tournament=t)
         populate_feedback_scores(self._adjudicators)
     return self._adjudicators
コード例 #6
0
ファイル: views.py プロジェクト: czlee/tabbycat
 def get_adjudicators(self):
     if not hasattr(self, '_adjudicators'):
         t = self.tournament
         if t.pref('share_adjs'):
             self._adjudicators = Adjudicator.objects.filter(Q(tournament=t) | Q(tournament__isnull=True))
         else:
             self._adjudicators = Adjudicator.objects.filter(tournament=t)
         populate_feedback_scores(self._adjudicators)
     return self._adjudicators
コード例 #7
0
ファイル: views.py プロジェクト: daigo-kimura/tabbycat
 def get_table(self):
     t = self.get_tournament()
     adjudicators = self.get_adjudicators()
     populate_feedback_scores(adjudicators)
     # Gather stats necessary to construct the graphs
     adjudicators = get_feedback_overview(t, adjudicators)
     table = FeedbackTableBuilder(view=self,
                                  sort_key=self.sort_key,
                                  sort_order=self.sort_order)
     table = self.annotate_table(table, adjudicators)
     return table
コード例 #8
0
 def get_table(self):
     t = self.get_tournament()
     adjudicators = self.get_adjudicators()
     populate_feedback_scores(adjudicators)
     adjudicators = get_feedback_overview(t, adjudicators)
     table = FeedbackTableBuilder(view=self, sort_key='Overall Score',
                                  sort_order='desc')
     table.add_adjudicator_columns(adjudicators, hide_institution=True, subtext='institution')
     table.add_breaking_checkbox(adjudicators)
     table.add_score_columns(adjudicators)
     table.add_feedback_graphs(adjudicators)
     table.add_feedback_link_columns(adjudicators)
     table.add_feedback_misc_columns(adjudicators)
     return table
コード例 #9
0
ファイル: utils.py プロジェクト: czlee/tabbycat
def adjs_to_json(adjs, regions, t):
    """Converts to a standard JSON object for Vue components to use"""

    populate_feedback_scores(adjs)
    fw = t.current_round.feedback_weight
    for adj in adjs:
        adj.abs_score = adj.weighted_score(fw)

    absolute_scores = [adj.abs_score for adj in adjs]
    absolute_scores.sort()
    percentile_cutoffs = [(100 - i, percentile(absolute_scores, i / 100)) for i in range(0, 100, 10)]
    percentile_cutoffs.reverse()

    data = {}
    for adj in adjs:
        data[adj.id] = {
            "type": "adjudicator",
            "id": adj.id,
            "name": adj.name,
            "gender": adj.gender,
            "gender_show": False,
            "region": [r for r in regions if r["id"] is adj.institution.region_id][0]
            if adj.institution.region_id is not None
            else "",
            "region_show": False,
            "institution": {
                "id": adj.institution.id,
                "name": adj.institution.code,
                "code": adj.institution.code,
                "abbreviation": adj.institution.abbreviation,
            },
            "score": "%.1f" % adj.abs_score,
            "ranking": next(pc[0] for pc in percentile_cutoffs if pc[1] <= adj.abs_score),
            "histories": adj.histories,
            "conflicts": {
                "teams": adj.personal_teams,
                "institutions": adj.institutional_institutions,
                "adjudicators": adj.personal_adjudicators,
            },
            "conflicted": {
                "hover": {"personal": False, "institutional": False, "history": False, "history_ago": 99},
                "panel": {"personal": False, "institutional": False, "history": False, "history_ago": 99},
            },
        }

    return json.dumps(data)
コード例 #10
0
 def get_table(self):
     t = self.get_tournament()
     adjudicators = self.get_adjudicators()
     populate_feedback_scores(adjudicators)
     # Gather stats necessary to construct the graphs
     adjudicators = get_feedback_overview(t, adjudicators)
     table = FeedbackTableBuilder(view=self,
                                  sort_key='Overall Score',
                                  sort_order='desc')
     table.add_adjudicator_columns(adjudicators,
                                   hide_institution=True,
                                   subtext='institution')
     table.add_breaking_checkbox(adjudicators)
     table.add_score_columns(adjudicators)
     table.add_feedback_graphs(adjudicators)
     table.add_feedback_link_columns(adjudicators)
     table.add_feedback_misc_columns(adjudicators)
     return table
コード例 #11
0
ファイル: mixins.py プロジェクト: czlee/tabbycat
    def get_draw(self):
        # The use-case for prefetches here is so intense that we'll just implement
        # a separate one (as opposed to use Round.debate_set_with_prefetches())
        draw = self.round.debate_set.select_related('round__tournament', 'venue').prefetch_related(
            Prefetch('debateadjudicator_set',
                queryset=DebateAdjudicator.objects.select_related('adjudicator__institution__region')),
            Prefetch('debateteam_set',
                queryset=DebateTeam.objects.select_related(
                    'team__institution__region'
                ).prefetch_related(
                    Prefetch('team__speaker_set', queryset=Speaker.objects.order_by('name')),
                )),
            'debateteam_set__team__break_categories',
            'venue__venuecategory_set',
        )
        populate_win_counts([dt.team for debate in draw for dt in debate.debateteam_set.all()])
        populate_feedback_scores([da.adjudicator for debate in draw for da in debate.debateadjudicator_set.all()])

        serialised_draw = [d.serialize() for d in draw]
        draw = self.annotate_draw(draw, serialised_draw)
        return json.dumps(serialised_draw)
コード例 #12
0
ファイル: utils.py プロジェクト: modale/tabbycat
def adjs_to_json(adjs, regions, t):
    """Converts to a standard JSON object for Vue components to use"""

    populate_feedback_scores(adjs)
    fw = t.current_round.feedback_weight
    for adj in adjs:
        adj.abs_score = adj.weighted_score(fw)

    absolute_scores = [adj.abs_score for adj in adjs]
    absolute_scores.sort()
    percentile_cutoffs = [(100 - i, percentile(absolute_scores, i / 100))
                          for i in range(0, 100, 10)]
    percentile_cutoffs.reverse()

    data = {}
    for adj in adjs:
        data[adj.id] = {
            'type':
            'adjudicator',
            'id':
            adj.id,
            'name':
            adj.name,
            'gender':
            adj.gender,
            'gender_show':
            False,
            'region':
            [r for r in regions if r['id'] is adj.institution.region_id][0]
            if adj.institution.region_id is not None else '',
            'region_show':
            False,
            'institution': {
                'id': adj.institution.id,
                'name': adj.institution.code,
                'code': adj.institution.code,
                'abbreviation': adj.institution.abbreviation
            },
            'score':
            "%.1f" % adj.abs_score,
            'ranking':
            next(pc[0] for pc in percentile_cutoffs if pc[1] <= adj.abs_score),
            'histories':
            adj.histories,
            'conflicts': {
                'teams': adj.personal_teams,
                'institutions': adj.institutional_institutions,
                'adjudicators': adj.personal_adjudicators,
            },
            'conflicted': {
                'hover': {
                    'personal': False,
                    'institutional': False,
                    'history': False,
                    'history_ago': 99
                },
                'panel': {
                    'personal': False,
                    'institutional': False,
                    'history': False,
                    'history_ago': 99
                }
            }
        }

    return json.dumps(data)
コード例 #13
0
 def get_adjudicators(self):
     if not hasattr(self, '_adjudicators'):
         t = self.tournament
         self._adjudicators = Adjudicator.objects.filter(tournament=t)
         populate_feedback_scores(self._adjudicators)
     return self._adjudicators