initial commit

This commit is contained in:
artus40
2017-09-21 13:12:35 +02:00
parent a270cb55de
commit 2e0cde3552
31 changed files with 703 additions and 0 deletions

25
core/forms.py Normal file
View File

@@ -0,0 +1,25 @@
from django import forms
from .models import Enregistrement
class EnregistrementForm(forms.ModelForm):
est_negatif = forms.BooleanField(required=False)
class Meta:
model = Enregistrement
fields = ('montant', 'description', 'date', 'etiquette')
widgets = {'etiquette': forms.Select(
attrs={'class':'form-control custom-select'}
),
'date': forms.SelectDateWidget(
attrs={'class':'form-control custom-select mx-1'}
)
}
def clean(self):
data = super().clean()
print(data)
# Force un nombre négatif si 'est_negatif' est coché
if (data['est_negatif']
and data['montant'] > 0):
self.cleaned_data['montant'] = 0 - data['montant']
return self.cleaned_data