Prevent event swith enddate before startdate

This commit is contained in:
Magnus Hagander
2013-05-21 14:07:01 -04:00
parent 0ce425ffb1
commit 5f9d2023c7

View File

@ -39,6 +39,8 @@ class EventForm(forms.ModelForm):
if self.instance.pk and self.instance.approved:
if self.cleaned_data['enddate'] != self.instance.enddate:
raise ValidationError("You cannot change the dates on events that have been approved")
if self.cleaned_data['enddate'] < self.cleaned_data['startdate']:
raise ValidationError("End date cannot be before start date!")
return self.cleaned_data['enddate']
class Meta: