gestioCOF/kfet/forms.py

37 lines
1,005 B
Python
Raw Normal View History

2016-08-02 10:40:46 +02:00
from django import forms
from django.contrib.auth.models import User
from kfet.models import Account
from gestioncof.models import CofProfile
class AccountTrigrammeForm(forms.ModelForm):
class Meta:
model = Account
fields = ['trigramme']
widgets = {
'trigramme': forms.TextInput(attrs={'autocomplete': 'off'}),
}
class AccountForm(forms.ModelForm):
class Meta:
model = Account
fields = ['promo', 'nickname']
class CofForm(forms.ModelForm):
def clean_is_cof(self):
instance = getattr(self, 'instance', None)
if instance and instance.pk:
return instance.is_cof
else:
return False
class Meta:
model = CofProfile
fields = ['login_clipper', 'is_cof', 'departement']
class UserForm(forms.ModelForm):
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email']
help_texts = {
'username': ''
}