<reponame>TolimanStaR/Course-Work<gh_stars>1-10
from django.contrib.auth.models import User
from django import forms
from .models import UserProfile


class LoginForm(forms.Form):
    username = forms.CharField()
    password = forms.CharField(widget=forms.PasswordInput)


class UserRegistrationForm(forms.ModelForm):
    password = forms.CharField(label='В<PASSWORD>ите пар<PASSWORD>', widget=forms.PasswordInput)
    password2 = forms.CharField(label='<PASSWORD>', widget=forms.PasswordInput)

    class Meta:
        model = User
        fields = ('username', 'email')

    def clean_password2(self):
        clean_data = self.cleaned_data
        if clean_data['password'] != clean_data['password2']:
            raise forms.ValidationError('Пароли не совпадают!')

        return clean_data['password2']


class UserEditForm(forms.ModelForm):
    class Meta:
        model = User
        fields = (
            'first_name',
            'last_name',
            'email',
        )


class UserProfileEditForm(forms.ModelForm):
    class Meta:
        model = UserProfile
        fields = ('profile_image', 'about',)
