from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm


class addUserForm(UserCreationForm):
    first_name = forms.CharField(label='FirstName', widget=forms.TextInput(
        attrs={'placeholder': 'Enter your firstname', 'id': 'first_name', 'class': 'form-control'}), max_length=50, required=True, help_text='Required. 50 characters or fewer. Letters only.')

    last_name = forms.CharField(label='LastName', widget=forms.TextInput(
        attrs={'placeholder': 'Enter your lastname', 'id': 'last_name', 'class': 'form-control'}), max_length=50, required=True, help_text='Required. 150 characters or fewer. Letters')
    email = forms.EmailField(label='Email', widget=forms.EmailInput(attrs={
                             'placeholder': 'Enter your email', 'id': 'user_email', 'class': 'form-control'}), max_length=50, required=True, help_text='Required.add valid email address')
    username = forms.CharField(label='Username', widget=forms.TextInput(attrs={'placeholder': 'Enter your username', 'id': 'user_name',
                               'class': 'form-control'}), max_length=50, required=True, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.')
    password1 = forms.CharField(label='Password', widget=forms.PasswordInput(
        attrs={'placeholder': 'Enter your password', 'id': 'user_password', 'class': 'form-control'}), max_length=50, required=True, help_text='Your password must contain at least 8 characters.')
    password2 = forms.CharField(label='Confirm Password', widget=forms.PasswordInput(
        attrs={'placeholder': 'Enter confirm password', 'id': 'confirm_password', 'class': 'form-control'}), max_length=50, required=True, help_text='Enter the same password as before, for verification.')

    user_role = forms.CharField(label='User_role', widget=forms.TextInput(
        attrs={'placeholder': 'Select your group', 'id': 'user_group', 'class': 'form-control'}), max_length=50, required=True, help_text='Required. 150 characters or fewer. Letters')

    class Meta:
        model = User
        fields = ['first_name', 'last_name', 'username',
                  'email', 'password1', 'password2','user_role']


class UserUpadte(forms.ModelForm):
    class Meta:
        model = User
        fields = '__all__'
