<commit_before>from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import Group
from django.utils.safestring import mark_safe
from django.contrib.auth import get_user_model

from . import settings as accounts_settings

attrs_dict = {'class': 'required'}

USERNAME_RE = r'^[\.\w]+$'


class PasswordLinkWidget(forms.Widget):
    def render(self, name, value, attrs=None):
        return mark_safe(u'<a href="../password/" id="password-link">Change</a>')


class UserForm(forms.ModelForm):
    password = forms.CharField(required=False, widget=PasswordLinkWidget())
    groups = forms.ModelMultipleChoiceField(required=False,
                queryset=Group.objects.all().order_by('name'))

    def clean(self):
        if self.is_valid():
            self.cleaned_data['password'] = <PASSWORD>
            return self.cleaned_data

        if hasattr(self, 'cleaned_data'):
            return self.cleaned_data
        else:
            return {}

    class Meta:
        model = get_user_model()


class SignupModelForm(forms.ModelForm):
    """
    Form for creating a new user account.
    Validates that the requested username and e-mail is not already in use.
    Also requires the password to be entered twice.
    """
    first_name = forms.CharField(label=_('First name'), max_length=30)
    last_name = forms.CharField(label=_('Last name'), max_length=30)
    username = forms.RegexField(regex=USERNAME_RE,
                                max_length=30,
                                widget=forms.TextInput(attrs=attrs_dict),
                                label=_("Username"),
                                error_messages={'invalid': _('Username must contain only letters, numbers, dots and underscores.')})
    email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
                                                               maxlength=75)),<commit_msg>Models forms require exclude to be set<commit_after>from django import forms
from django.utils.translation import ugettext_lazy as _
from django.contrib.auth.models import Group
from django.utils.safestring import mark_safe
from django.contrib.auth import get_user_model

from . import settings as accounts_settings

attrs_dict = {'class': 'required'}

USERNAME_RE = r'^[\.\w]+$'


class PasswordLinkWidget(forms.Widget):
    def render(self, name, value, attrs=None):
        return mark_safe(u'<a href="../password/" id="password-link">Change</a>')


class UserForm(forms.ModelForm):
    password = forms.CharField(required=False, widget=PasswordLinkWidget())
    groups = forms.ModelMultipleChoiceField(required=False,
                queryset=Group.objects.all().order_by('name'))

    def clean(self):
        if self.is_valid():
            self.cleaned_data['password'] = <PASSWORD>
            return self.cleaned_data

        if hasattr(self, 'cleaned_data'):
            return self.cleaned_data
        else:
            return {}

    class Meta:
        model = get_user_model()
        exclude = []


class SignupModelForm(forms.ModelForm):
    """
    Form for creating a new user account.
    Validates that the requested username and e-mail is not already in use.
    Also requires the password to be entered twice.
    """
    first_name = forms.CharField(label=_('First name'), max_length=30)
    last_name = forms.CharField(label=_('Last name'), max_length=30)
    username = forms.RegexField(regex=USERNAME_RE,
                                max_length=30,
                                widget=forms.TextInput(attrs=attrs_dict),
                                label=_("Username"),
                                error_messages={'invalid': _('Username must contain only letters, numbers, dots and underscores.')})
    email = forms.EmailField(widget=forms.TextInput(attrs=dict(attrs_dict,
                                                               maxlength=75)),
{'fraction_non_alphanumeric': 0.10431472081218274, 'fraction_numerical': 0.0040609137055837565, 'mean_word_length': 2.5697463768115942, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6855414', 'n_tokens_mistral': 1076, 'n_tokens_neox': 1045, 'n_words': 254}