Example #1
0
    def _initial_data(self):
        """Generates dictionary of initial form data."""

        ballotset = BallotSet(self.ballotsub)
        initial = {
            'debate_result_status': self.debate.result_status,
            'confirmed': ballotset.confirmed,
            'discarded': ballotset.discarded
        }

        # HACK: Check here to see if self.ballotsub has been saved -- if it's not,
        # then it's a new ballot set, and choose_sides should not be populated
        # with an initial value. Fix when models support a proper "no side
        # assigned" state (it currently doesn't).
        if self.choosing_sides and self.ballotsub.pk is not None:
            try:
                initial['choose_sides'] = str(
                    self.debate.aff_team.id) + "," + str(
                        self.debate.neg_team.id)
            except m.DebateTeam.DoesNotExist:
                pass

        # Generally, initialise the motion to what is currently in the database.
        # But if there is only one motion and no motion is currently stored in
        # the database for this round, then default to the only motion there is.
        if self.using_motions:
            if not ballotset.motion and self.motions.count() == 1:
                initial['motion'] = self.motions.get()
            else:
                initial['motion'] = ballotset.motion
            for side in self.SIDES:
                initial[self._fieldname_motion_veto(
                    side)] = ballotset.get_motion_veto(side)

        for side, pos in self.SIDES_AND_POSITIONS:
            speaker = ballotset.get_speaker(side, pos)
            if speaker:
                initial[self._fieldname_speaker(side, pos)] = speaker.pk
                for adj in self.adjudicators:
                    score = ballotset.get_score(adj, side, pos)
                    initial[self._fieldname_score(adj, side, pos)] = score

        return initial
Example #2
0
    def _initial_data(self):
        """Generates dictionary of initial form data."""

        ballotset = BallotSet(self.ballotsub)
        initial = {'debate_result_status': self.debate.result_status,
                'confirmed': ballotset.confirmed, 'discarded': ballotset.discarded}

        # HACK: Check here to see if self.ballotsub has been saved -- if it's not,
        # then it's a new ballot set, and choose_sides should not be populated
        # with an initial value. Fix when models support a proper "no side
        # assigned" state (it currently doesn't).
        if self.choosing_sides and self.ballotsub.pk is not None:
            try:
                initial['choose_sides'] = str(self.debate.aff_team.id) + "," + str(self.debate.neg_team.id)
            except m.DebateTeam.DoesNotExist:
                pass

        # Generally, initialise the motion to what is currently in the database.
        # But if there is only one motion and no motion is currently stored in
        # the database for this round, then default to the only motion there is.
        if self.using_motions:
            if not ballotset.motion and self.motions.count() == 1:
                initial['motion'] = self.motions.get()
            else:
                initial['motion'] = ballotset.motion
            for side in self.SIDES:
                initial[self._fieldname_motion_veto(side)] = ballotset.get_motion_veto(side)

        for side, pos in self.SIDES_AND_POSITIONS:
            speaker = ballotset.get_speaker(side, pos)
            if speaker:
                initial[self._fieldname_speaker(side, pos)] = speaker.pk
                for adj in self.adjudicators:
                    score = ballotset.get_score(adj, side, pos)
                    initial[self._fieldname_score(adj, side, pos)] = score

        return initial
Example #3
0
    def _initial_data(self):
        """
        Generate dictionary of initial form data
        """

        initial = {'debate_result_status': self.debate.result_status}

        bs = BallotSet(self.ballots)

        initial['confirmed'] = bs.confirmed
        initial['discarded'] = bs.discarded

        # This isn't relevant if we're not showing the motions field
        # (i.e. there are no motions given for this round).
        # Generally, initialise the motion to what is currently in the
        # database.  But if there is only one motion and no motion is
        # currently stored in the database for this round, then default
        # to the only motion there is.
        if self.show_motion:
            if not bs.motion and self.motions.count() == 1:
                initial['motion'] = self.motions.get()
            else:
                initial['motion'] = bs.motion
            initial['aff_motion_veto'] = bs.aff_motion_veto
            initial['neg_motion_veto'] = bs.neg_motion_veto

        for side in ('aff', 'neg'):
            for i in self.POSITIONS:
                speaker = bs.get_speaker(side, i)
                if speaker:
                    initial['%s_speaker_%d' % (side, i)] = speaker.id

                    for adj in self.adjudicators:
                        score = bs.get_score(adj, side, i)
                        initial[self.score_field_name(adj, side, i)] = score

        return initial