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

class SendComment(forms.ModelForm):
    class Meta:
        model = Comment
        fields = ('name', 'email', 'text')
        widgets = {
            'name': forms.TextInput(attrs={'class': 'form-control'}),
            'email': forms.TextInput(attrs={'class': 'form-control'}),
            'text': forms.Textarea(attrs={'class': 'form-control', 'rows': 4}),
            }

class SignUpForm(UserCreationForm):
    password1 = forms.CharField(
        widget = forms.PasswordInput(
            attrs={'class': 'form-control', 'style': 'width: 100%'}
            )
        )
    password2 = forms.CharField(
        widget=forms.PasswordInput(attrs={'class': 'form-control'})
        )
    email = forms.CharField(
        max_length = 254,
        required = True,
        widget=forms.TextInput(attrs={'class': 'form-control'})
        )
    class Meta:
        model = User
        fields = (
            'username',
            'first_name',
            'last_name',
            'email',
            'password1',
            'password2',
            )
        widgets = {
            'first_name': forms.TextInput(attrs={'class': 'form-control'}),
            'last_name':  forms.TextInput(attrs={'class': 'form-control'}),
            'username':   forms.TextInput(attrs={'class': 'form-control'}),            
            }

class UserLogin(forms.Form):
    username = forms.CharField(
        label = 'نام کاربری',
        max_length = 254,
        required = True,
        widget = forms.TextInput(attrs={'class': 'form-control'})
        )
    password = forms.CharField(
        label = 'رمز عبور',
        required = True,
        widget = forms.PasswordInput(attrs={'class': 'form-control'})
        )