37 lines
1,005 B
Python
37 lines
1,005 B
Python
|
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': ''
|
||
|
}
|