from django import forms


class RegisterForm(forms.Form):
    username = forms.CharField(max_length= 50, label= "Kullanıcı Adı:")
    #email = forms.EmailField(max_length=20, label="Email")
    password = forms.CharField(max_length=20, label="Parola", widget=forms.PasswordInput)
    confirm = forms.CharField(max_length=20, label="Parola Doğrula", widget=forms.PasswordInput)

    def clean(self):
        username = self.cleaned_data.get("username")
        password = self.cleaned_data.get("password")
        confirm = self.cleaned_data.get("confirm")

        if username is None:
            raise forms.ValidationError("Kullanıcı Adı boş bırakılamaz.")

        if password and confirm and password != confirm:
            raise forms.ValidationError("Parolalar Eşleşmiyor !")


        values = {
            "username" : username,
            "password" : password
        }
        return values



class LoginForm(forms.Form):
    username = forms.CharField(max_length= 50, label= "Kullanıcı Adı:")
    password = forms.CharField(max_length=20, label="Parola", widget=forms.PasswordInput)
