diff --git a/pendencies/forms.py b/pendencies/forms.py index 95e29fc..bc27bc2 100644 --- a/pendencies/forms.py +++ b/pendencies/forms.py @@ -24,10 +24,10 @@ class PendenciesForm(forms.ModelForm): self.fields['begin_date'].input_formats = datetime_formats self.fields['end_date'].input_formats = datetime_formats - + begin_date_check = forms.BooleanField(required = False) end_date_check = forms.BooleanField(required = False) - + class Meta: model = Pendencies fields = ['action', 'begin_date', 'end_date'] @@ -99,11 +99,11 @@ class PendenciesLimitedForm(forms.ModelForm): self.fields['begin_date'].input_formats = datetime_formats self.fields['end_date'].input_formats = datetime_formats self.fields['limit_date'].input_formats = datetime_formats - + begin_date_check = forms.BooleanField(required = False) end_date_check = forms.BooleanField(required = False) limit_date_check = forms.BooleanField(required = False) - + class Meta: model = Pendencies fields = ['action', 'begin_date', 'end_date', 'limit_date'] @@ -144,13 +144,13 @@ class PendenciesLimitedForm(forms.ModelForm): if begin_date and limit_date: if not begin_date == ValueError and not limit_date == ValueError: - if begin_date > limit_date: + if begin_date.date() > limit_date.date(): self.add_error('begin_date', _('This input should be filled with a date equal or before the Limit Date.')) self.add_error('limit_date', _('This input should be filled with a date equal or after the Begin Date.')) if end_date and limit_date: if not end_date == ValueError and not limit_date == ValueError: - if end_date > limit_date: + if end_date.date() > limit_date.date(): self.add_error('end_date', _('This input should be filled with a date equal or before the Limit Date.')) self.add_error('limit_date', _('This input should be filled with a date equal or after the End Date.')) @@ -192,15 +192,15 @@ class PendenciesLimitedForm(forms.ModelForm): limit_submission_date = timezone.make_aware(limit_submission_date, timezone.get_current_timezone()) if not begin_date == ValueError and begin_date: - if begin_date > limit_submission_date: + if begin_date.date() > limit_submission_date.date(): self.add_error('begin_date', _('This input should be filled with a date equal or before the goals submission limit date.')) if not end_date == ValueError and end_date: - if end_date > limit_submission_date: + if end_date.date() > limit_submission_date.date(): self.add_error('end_date', _('This input should be filled with a date equal or before the goals submission limit date.')) if not limit_date == ValueError and limit_date: - if limit_date > limit_submission_date: + if limit_date.date() > limit_submission_date.date(): self.add_error('limit_date', _('This input should be filled with a date equal or before the goals submission limit date.')) return cleaned_data diff --git a/subjects/forms.py b/subjects/forms.py index 46f168a..3596053 100644 --- a/subjects/forms.py +++ b/subjects/forms.py @@ -172,14 +172,14 @@ class UpdateSubjectForm(forms.ModelForm): return name - def clean_subscribe_begin(self): - subscribe_begin = self.cleaned_data['subscribe_begin'] - - if subscribe_begin < datetime.datetime.today().date() and subscribe_begin < self.instance.subscribe_begin: - self._errors['subscribe_begin'] = [_('This date must be today or after')] - return ValueError - - return subscribe_begin + # def clean_subscribe_begin(self): + # subscribe_begin = self.cleaned_data['subscribe_begin'] + # + # if subscribe_begin < datetime.datetime.today().date() and subscribe_begin < self.instance.subscribe_begin: + # self._errors['subscribe_begin'] = [_('This date must be today or after')] + # return ValueError + # + # return subscribe_begin def clean_subscribe_end(self): subscribe_end = self.cleaned_data['subscribe_end'] -- libgit2 0.21.2