# Path: reformedacademy/models.py
# class User(AbstractUser):
#     biography = models.TextField(blank=True)
#     profile_image = models.ImageField(upload_to='profile_images', blank=True)
# 
#     def __str__(self):
#         return '{} {}'.format(self.first_name, self.last_name)
# 
#     # def progress_for_course(self, course):
#     #     """Gets the progress for a course."""
#     #     return self.courseprogress_set.filter(course=course).first()


from django import forms
from django.contrib.auth import authenticate
from django.forms import widgets
from reformedacademy.models import User

        # Check if email address is unique
        if User.objects.filter(email=email).exists():
            raise forms.ValidationError(
                'Email address is already in use. Do you already have an account?')

        # Check if passwords are the same
        if password != password_confirmation:
            raise forms.ValidationError('Passwords are not the same.')

        return cleaned_data


class LoginForm(forms.Form):
    email = forms.EmailField(required=True, max_length=75)
    password = forms.CharField(widget=widgets.PasswordInput, required=True)


class ProfileForm(forms.Form):
    email = forms.EmailField(required=True, max_length=75)

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(ProfileForm, self).__init__(*args, **kwargs)

    def clean(self):
        cleaned_data = super(ProfileForm, self).clean()
        email = cleaned_data.get('email')

        # Check if email address is unique

# Path: reformedacademy/models.py
# class User(AbstractUser):
#     biography = models.TextField(blank=True)
#     profile_image = models.ImageField(upload_to='profile_images', blank=True)
# 
#     def __str__(self):
#         return '{} {}'.format(self.first_name, self.last_name)
# 
#     # def progress_for_course(self, course):
#     #     """Gets the progress for a course."""
#     #     return self.courseprogress_set.filter(course=course).first()


# Path: reformedacademy/forms.py
from django import forms
from django.contrib.auth import authenticate
from django.forms import widgets
from reformedacademy.models import User


        # Check if email address is unique
        if User.objects.filter(email=email).exists():
            raise forms.ValidationError(
                'Email address is already in use. Do you already have an account?')

        # Check if passwords are the same
        if password != password_confirmation:
            raise forms.ValidationError('Passwords are not the same.')

        return cleaned_data


class LoginForm(forms.Form):
    email = forms.EmailField(required=True, max_length=75)
    password = forms.CharField(widget=widgets.PasswordInput, required=True)


class ProfileForm(forms.Form):
    email = forms.EmailField(required=True, max_length=75)

    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user', None)
        super(ProfileForm, self).__init__(*args, **kwargs)

    def clean(self):
        cleaned_data = super(ProfileForm, self).clean()
        email = cleaned_data.get('email')

        # Check if email address is unique

        if User.objects.filter(email=email).exclude(pk=self.user.pk).exists():