2020-07-06 23:40:56 +02:00
|
|
|
from django import forms
|
|
|
|
from django.contrib.auth import get_user_model
|
2020-07-21 14:49:37 +02:00
|
|
|
from django.contrib.auth.forms import UserCreationForm
|
2021-01-27 22:25:58 +01:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2020-07-06 23:40:56 +02:00
|
|
|
|
|
|
|
from bds.models import BDSProfile
|
|
|
|
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
|
|
|
|
|
|
class UserForm(forms.ModelForm):
|
2021-01-29 23:53:26 +01:00
|
|
|
is_buro = forms.BooleanField(label=_("Membre du Burô"), required=False)
|
2021-01-27 22:25:58 +01:00
|
|
|
|
2020-07-06 23:40:56 +02:00
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ["email", "first_name", "last_name"]
|
|
|
|
|
|
|
|
|
2020-07-21 14:49:37 +02:00
|
|
|
class UserFromClipperForm(forms.ModelForm):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.fields["username"].disabled = True
|
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ["username", "email", "first_name", "last_name"]
|
|
|
|
|
|
|
|
|
|
|
|
class UserFromScratchForm(UserCreationForm):
|
|
|
|
class Meta:
|
|
|
|
model = User
|
|
|
|
fields = ["username", "email", "first_name", "last_name"]
|
|
|
|
|
|
|
|
|
2020-07-06 23:40:56 +02:00
|
|
|
class ProfileForm(forms.ModelForm):
|
|
|
|
class Meta:
|
|
|
|
model = BDSProfile
|
|
|
|
exclude = ["user"]
|
2021-10-26 09:24:44 +02:00
|
|
|
widgets = {
|
|
|
|
"birthdate": forms.DateInput(attrs={"type": "date"}, format="%Y-%m-%d")
|
|
|
|
}
|