69b0b13ad3
- PEP8 - Fichiers inutilisés
59 lines
2.1 KiB
Python
59 lines
2.1 KiB
Python
from django import forms
|
|
from gestion.models import ErnestoUser
|
|
from django.contrib.auth.models import User
|
|
from django.contrib.auth.forms import UserCreationForm
|
|
|
|
|
|
class RegistrationFormUser(UserCreationForm):
|
|
class Meta:
|
|
model = User
|
|
fields = ('username', 'first_name', 'last_name', 'password1',
|
|
'password2', 'email',)
|
|
|
|
|
|
class InscriptionMembreForm(forms.ModelForm):
|
|
validation = forms.CharField(max_length=100, widget=forms.PasswordInput)
|
|
|
|
class Meta:
|
|
model = ErnestoUser
|
|
fields = ("phone", "instru", )
|
|
|
|
|
|
class ChangeMembreForm(forms.ModelForm):
|
|
first_name = forms.CharField(max_length=30, required=False)
|
|
last_name = forms.CharField(max_length=50, required=False)
|
|
email = forms.EmailField()
|
|
mails = forms.BooleanField(label="Recevoir les mails", required=False)
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(ChangeMembreForm, self).__init__(*args, **kwargs)
|
|
self.fields['first_name'].initial = self.instance.first_name
|
|
self.fields['last_name'].initial = self.instance.last_name
|
|
self.fields['email'].initial = self.instance.email
|
|
self.fields['instru'].initial = self.instance.profile.instru
|
|
self.fields["phone"].initial = self.instance.profile.phone
|
|
self.fields["mails"].initial = self.instance.profile.mails
|
|
|
|
self.fields.keyOrder = [
|
|
'first_name',
|
|
'last_name',
|
|
'email',
|
|
'phone',
|
|
'instru',
|
|
'mails',
|
|
]
|
|
|
|
def save(self, *args, **kwargs):
|
|
super(ChangeMembreForm, self).save(*args, **kwargs)
|
|
self.instance.first_name = self.cleaned_data['first_name']
|
|
self.instance.last_name = self.cleaned_data['last_name']
|
|
self.instance.email = self.cleaned_data['email']
|
|
self.instance.profile.instru = self.cleaned_data["instru"]
|
|
self.instance.profile.phone = self.cleaned_data["phone"]
|
|
self.instance.profile.mails = self.cleaned_data["mails"]
|
|
self.instance.save()
|
|
self.instance.profile.save()
|
|
|
|
class Meta:
|
|
model = ErnestoUser
|
|
fields = ("phone", "instru", "mails")
|