Project

General

Profile

« Previous | Next » 

Revision 53647eb3

Added by Serghei Mihai over 10 years ago

absences management refactored

View differences:

calebasse/personnes/forms.py
179 179
                'comment': forms.Textarea(attrs={'rows': 3}),
180 180
        }
181 181

  
182
class HolidayForm(forms.ModelForm):
183

  
184
    class Meta:
185
        model = Holiday
186
        widgets = {
187
            'comment': forms.Textarea(attrs = {'rows': 3, 'cols': 18}),
188
            'start_date': forms.TextInput(attrs = {'size': 10}),
189
            'end_date': forms.TextInput(attrs = {'size': 10}),
190
            }
191

  
192
    def clean(self):
193
        cleaned_data = super(HolidayForm, self).clean()
194
        if cleaned_data.get('start_date') and cleaned_data.get('end_date'):
195
            if cleaned_data['start_date'] > cleaned_data['end_date']:
196
                raise forms.ValidationError(u'La date de début doit être supérieure à la date de fin')
197
        return cleaned_data
198

  
182 199
HolidayFormSet = inlineformset_factory(
183 200
        Worker, Holiday,
184 201
        form=BaseHolidayForm,

Also available in: Unified diff