Commit afb39799 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki
Browse files

Check project dates (better implementation)

parent 57292428
......@@ -775,8 +775,7 @@ class ProjectApplicationForm(forms.ModelForm):
def clean_start_date(self):
start_date = self.cleaned_data.get('start_date')
if not self.precursor_application:
now = datetime.now()
if start_date and now - start_date > timedelta(days=1):
if start_date and (start_date - datetime.now()).days < 0:
raise forms.ValidationError(
_(astakos_messages.INVALID_PROJECT_START_DATE))
return start_date
......@@ -785,10 +784,10 @@ class ProjectApplicationForm(forms.ModelForm):
start_date = self.cleaned_data.get('start_date')
end_date = self.cleaned_data.get('end_date')
now = datetime.now()
if end_date and now - end_date > timedelta(days=1):
if end_date and (end_date - now).days < 0:
raise forms.ValidationError(
_(astakos_messages.INVALID_PROJECT_END_DATE))
if start_date and end_date <= start_date:
if start_date and (end_date - start_date).days <= 0:
raise forms.ValidationError(
_(astakos_messages.INCONSISTENT_PROJECT_DATES))
return end_date
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment