fix batch action desactiviation
[auf_rh_dae.git] / project / rh / forms.py
CommitLineData
84cbb4c5
OL
1# -*- encoding: utf-8 -*-
2
3from django import forms
cf022e27 4from models import Dossier, Contrat, AyantDroit
84cbb4c5
OL
5
6
7class FormDate(object):
8
9 def clean_date_fin(self):
10 date_fin = self.cleaned_data['date_fin']
11 if date_fin is None:
12 return date_fin
13 date_debut = self.cleaned_data['date_debut']
14 if date_fin < date_debut:
3f5f3898 15 raise forms.ValidationError(u"La date de fin est antérieure à la date de début")
84cbb4c5
OL
16 return date_fin
17
18class DossierForm(forms.ModelForm, FormDate):
19
20 class Model:
21 model = Dossier
22
23class ContratForm(forms.ModelForm, FormDate):
24
25 class Model:
26 model = Contrat
cf022e27
OL
27
28class AyantDroitForm(forms.ModelForm):
29
30 def __init__(self, *args, **kwargs):
31 super(AyantDroitForm, self).__init__(*args, **kwargs)
32 self.fields['date_naissance'].widget = forms.widgets.DateInput()
33
34 class Meta:
35 model = AyantDroit
36
37