<commit_before>from django import forms
from django.contrib.auth.forms import UserCreationForm as BaseUserCreationForm
from django.contrib.auth.forms import UserChangeForm as BaseUserChangeForm
from django.forms import ModelForm

from .models import User, Membership


class UserCreationForm(BaseUserCreationForm):
    email = forms.EmailField()

    class Meta(BaseUserCreationForm.Meta):
        model = User
        fields = (
            'username',
            'email',
            '<PASSWORD>',
            '<PASSWORD>',
        )

    def clean_username(self):
        # Since User.username is unique, this check is redundant,
        # but it sets a nicer error message than the ORM. See #13147.
        username = self.cleaned_data["username"]
        try:
            User._default_manager.get(username=username)
        except User.DoesNotExist:
            return username
        raise forms.ValidationError(self.error_messages['duplicate_username'])

    def clean_email(self):
        """ Ensure email is unique """
        email = self.cleaned_data["email"]
        print(email)
        try:
            User._default_manager.get(email=email)
        except User.DoesNotExist:
            return email

        raise forms.ValidationError("A user with this email address has already been registered")


class UserChangeForm(BaseUserChangeForm):
    class Meta(BaseUserChangeForm.Meta):
        model = User


class UserProfileForm(ModelForm):

    class Meta:
        model = User
        fields = [
            'first_name',
            'last_name',
            'email',
            'bio',
            'search_visibility',
            'email_privacy',
            'public_profile',
        ]
        widgets = {
            'search_visibility': forms.RadioSelect,
            'email_privacy': forms.RadioSelect,<commit_msg>Delete a debug print.<commit_after>from django import forms
from django.contrib.auth.forms import UserCreationForm as BaseUserCreationForm
from django.contrib.auth.forms import UserChangeForm as BaseUserChangeForm
from django.forms import ModelForm

from .models import User, Membership


class UserCreationForm(BaseUserCreationForm):
    email = forms.EmailField()

    class Meta(BaseUserCreationForm.Meta):
        model = User
        fields = (
            'username',
            'email',
            '<PASSWORD>',
            '<PASSWORD>',
        )

    def clean_username(self):
        # Since User.username is unique, this check is redundant,
        # but it sets a nicer error message than the ORM. See #13147.
        username = self.cleaned_data["username"]
        try:
            User._default_manager.get(username=username)
        except User.DoesNotExist:
            return username
        raise forms.ValidationError(self.error_messages['duplicate_username'])

    def clean_email(self):
        """ Ensure email is unique """
        email = self.cleaned_data["email"]
        try:
            User._default_manager.get(email=email)
        except User.DoesNotExist:
            return email

        raise forms.ValidationError("A user with this email address has already been registered")


class UserChangeForm(BaseUserChangeForm):
    class Meta(BaseUserChangeForm.Meta):
        model = User


class UserProfileForm(ModelForm):

    class Meta:
        model = User
        fields = [
            'first_name',
            'last_name',
            'email',
            'bio',
            'search_visibility',
            'email_privacy',
            'public_profile',
        ]
        widgets = {
            'search_visibility': forms.RadioSelect,
            'email_privacy': forms.RadioSelect,
{'fraction_non_alphanumeric': 0.08426506681210799, 'fraction_numerical': 0.002727024815925825, 'mean_word_length': 2.257548845470693, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7270057', 'n_tokens_mistral': 956, 'n_tokens_neox': 931, 'n_words': 243}