Example #1
0
    def save(self, commit=True):
        instance = super(SimpleContestForm, self).save(commit=False)
        rounds = instance.round_set.all()
        if len(rounds) > 1:
            raise ValueError("SimpleContestForm does not support contests "
                             "with more than one round.")
        if len(rounds) == 1:
            round = rounds[0]
        else:
            instance.save()
            round = Round(contest=instance, name=_("Round 1"))
        round.start_date = self.cleaned_data['start_date']
        round.end_date = self.cleaned_data['end_date']
        round.results_date = self.cleaned_data['results_date']
        round.save()

        if commit:
            instance.save()

        return instance
Example #2
0
    def save(self, commit=True):
        instance = super(SimpleContestForm, self).save(commit=False)
        rounds = instance.round_set.all()
        if len(rounds) > 1:
            raise ValueError("SimpleContestForm does not support contests "
                    "with more than one round.")
        if len(rounds) == 1:
            round = rounds[0]
        else:
            instance.save()
            round = Round(contest=instance, name=_("Round 1"))
        round.start_date = self.cleaned_data['start_date']
        round.end_date = self.cleaned_data['end_date']
        round.results_date = self.cleaned_data['results_date']
        round.save()

        if commit:
            instance.save()

        return instance