Commit a0964a326515931eb3a21f2815bbb5a2c4e922f2
1 parent
5778f845
Exists in
master
and in
5 other branches
Fixing course date inputs [Issue: #226]
Showing
1 changed file
with
6 additions
and
6 deletions
Show diff stats
courses/forms.py
@@ -19,24 +19,24 @@ class CategoryCourseForm(forms.ModelForm): | @@ -19,24 +19,24 @@ class CategoryCourseForm(forms.ModelForm): | ||
19 | 19 | ||
20 | class CourseForm(forms.ModelForm): | 20 | class CourseForm(forms.ModelForm): |
21 | def clean_end_register_date(self): | 21 | def clean_end_register_date(self): |
22 | - init_register_date = self.data['init_register_date'] | ||
23 | - end_register_date = self.data['end_register_date'] | 22 | + init_register_date = self.cleaned_data['init_register_date'] |
23 | + end_register_date = self.cleaned_data['end_register_date'] | ||
24 | 24 | ||
25 | if init_register_date and end_register_date and end_register_date < init_register_date: | 25 | if init_register_date and end_register_date and end_register_date < init_register_date: |
26 | raise forms.ValidationError(_('The end date may not be before the start date.')) | 26 | raise forms.ValidationError(_('The end date may not be before the start date.')) |
27 | return end_register_date | 27 | return end_register_date |
28 | 28 | ||
29 | def clean_init_date(self): | 29 | def clean_init_date(self): |
30 | - end_register_date = self.data['end_register_date'] | ||
31 | - init_date = self.data['init_date'] | 30 | + end_register_date = self.cleaned_data['end_register_date'] |
31 | + init_date = self.cleaned_data['init_date'] | ||
32 | 32 | ||
33 | if end_register_date and init_date and init_date <= end_register_date: | 33 | if end_register_date and init_date and init_date <= end_register_date: |
34 | raise forms.ValidationError(_('The course start date must be after the end of registration.')) | 34 | raise forms.ValidationError(_('The course start date must be after the end of registration.')) |
35 | return init_date | 35 | return init_date |
36 | 36 | ||
37 | def clean_end_date(self): | 37 | def clean_end_date(self): |
38 | - init_date = self.data['init_date'] | ||
39 | - end_date = self.data['end_date'] | 38 | + init_date = self.cleaned_data['init_date'] |
39 | + end_date = self.cleaned_data['end_date'] | ||
40 | 40 | ||
41 | if init_date and end_date and end_date < init_date: | 41 | if init_date and end_date and end_date < init_date: |
42 | raise forms.ValidationError(_('The end date may not be before the start date.')) | 42 | raise forms.ValidationError(_('The end date may not be before the start date.')) |