from crispy_bulma.layout import Submit
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout
from django import forms
from django.contrib.auth.forms import UserChangeForm, UserCreationForm

from .models import CustomUser


class CustomUserCreationForm(UserCreationForm):
    class Meta:
        model = CustomUser
        fields = ("username", "first_name", "last_name", "password1", "password2")
        widgets = {
            "username": forms.TextInput(
                attrs={
                    "placeholder": "exemple@mail.fr",
                }
            ),
        }

    helper = FormHelper()
    helper.form_class = "form-horizontal"
    helper.layout = Layout(
        "username",
        "first_name",
        "last_name",
        "password1",
        "password2",
        Submit("submit", "Valider", css_class="is-primary"),
    )


class CustomUserChangeForm(UserChangeForm):  # pas encore utilisé - pour la V1
    class Meta:
        model = CustomUser
        fields = ("email", "first_name", "last_name")
