Exemple #1
0
    def clean(self):
        data = self.cleaned_data
        if self.request:
            can, reason = can_bet(self.request.user, self.topic,
                                  data.get('score'), yesno=data.get('yesno'))
            if not can:
                raise forms.ValidationError(reason)

        return data
Exemple #2
0
    def clean(self):
        data = self.cleaned_data
        if 'deadline' in data and data['deadline'] < timezone.now():
            raise forms.ValidationError(_('Deadline is not valid'))
        if 'event_close_date' in data and \
           data['event_close_date'] < data['deadline']:
            raise forms.ValidationError(
                _('Event close date should be after deadline'))

        if self.request and data.get('yesno') and data.get('score'):
            can, reason = can_bet(self.request.user, bet_score=data['score'], yesno=data['yesno'])
            if not can:
                raise forms.ValidationError(reason)

        return data