Beispiel #1
0
class LoginForm(forms.Form):
    username = forms.CharField(label=u'账号', widget=forms.TextInput(attrs={'class': 'form-control'}))
    password = forms.CharField(label=u'密码', widget=forms.PasswordInput(attrs={'class': 'form-control'}))
Beispiel #2
0
class UserForm(forms.Form):
    username = forms.CharField(label="用戶名", max_length=128, widget=forms.TextInput(attrs={'class': 'form-control'}))
    password = forms.CharField(label="密碼", max_length=256, widget=forms.PasswordInput(attrs={'class': 'form-control'}))
Beispiel #3
0
class SignupForm(forms.Form):
    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)),
        label=_("Email"))
    password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict,
                                                           render_value=False),
                                label=_("Create password"))
    password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict,
                                                           render_value=False),
                                label=_("Repeat password"))

    def clean_username(self):
        try:
            get_user_model().objects.get(
                username__iexact=self.cleaned_data['username'])
        except get_user_model().DoesNotExist:
            pass
        else:
            if USERENA_ACTIVATION_REQUIRED and UserenaSignup.objects.filter(
                    user__username__iexact=self.cleaned_data['username']
            ).exclude(activation_key=USERENA_ACTIVATED):
                raise forms.ValidationError(
                    _('This username is already taken but not '
                      'confirmed. Please check your email for '
                      'verification steps.'))
            raise forms.ValidationError(_('This username is already taken.'))
        if self.cleaned_data['username'].lower() in \
           USERENA_FORBIDDEN_USERNAMES:
            raise forms.ValidationError(_('This username is not allowed.'))
        return self.cleaned_data['username']

    def clean_email(self):
        """ Validate that the e-mail address is unique. """
        if get_user_model().objects.filter(
                email__iexact=self.cleaned_data['email']):
            if (USERENA_ACTIVATION_REQUIRED and UserenaSignup.objects.filter(
                    user__email__iexact=self.cleaned_data['email']).exclude(
                        activation_key=USERENA_ACTIVATED)):
                raise forms.ValidationError(
                    _('This email is already in use but not confirmed. '
                      'Please check your email for verification steps.'))
            raise forms.ValidationError(
                _('This email is already in use. '
                  'Please supply a different email.'))
        return self.cleaned_data['email']

    def clean(self):
        if ('password1' in self.cleaned_data
                and 'password2' in self.cleaned_data):
            if self.cleaned_data['password1'] != \
                   self.cleaned_data['password2']:
                raise forms.ValidationError(
                    _('The two password fields didn\'t match.'))
        return self.cleaned_data

    def save(self):
        username, email, password = (self.cleaned_data['username'],
                                     self.cleaned_data['email'],
                                     self.cleaned_data['password1'])

        new_user = UserenaSignup.objects.create_user(
            username, email, password, not USERENA_ACTIVATION_REQUIRED,
            USERENA_ACTIVATION_REQUIRED)
        return new_user
Beispiel #4
0
class UserForm(forms.ModelForm):
	password = forms.CharField(widget=forms.PasswordInput())
Beispiel #5
0
class LoginForm(forms.Form):
    userid = forms.CharField(widget=forms.TextInput(
        attrs={'class': 'form-control'}))
    password = forms.CharField(widget=forms.PasswordInput(
        attrs={'class': 'form-control'}))
Beispiel #6
0
class CreateUserForm(forms.Form):
	username = forms.CharField(label='username', max_length=100)
	password = forms.CharField(label='password', widget=forms.PasswordInput())
	email = forms.EmailField(label='email')
Beispiel #7
0
class UserForm(forms.Form):
    username = forms.CharField(label='用户名', max_length=128)
    password = forms.CharField(label='密  码', widget=forms.PasswordInput())
Beispiel #8
0
class LoginForm(forms.Form):
    username = forms.CharField(label = 'Tài khoản', max_length= 50)
    password =  forms.CharField(label= 'Mật khẩu',widget= forms.PasswordInput())
Beispiel #9
0
class ChangePassword(forms.Form):
    npassword = forms.CharField(label='Mật khẩu mới',widget=forms.PasswordInput())
Beispiel #10
0
class ExampleForm(forms.Form):
    name = forms.CharField()
    password = forms.CharField(widget=forms.PasswordInput())

    class Meta:
        fields = ('name', 'password')
Beispiel #11
0
class SignUpForm(forms.ModelForm):
    username = forms.CharField(widget=forms.TextInput(
        attrs={
            'class': 'form-control',
            'placeholder': 'Enter Username'
        }))

    dob = forms.DateField(widget=forms.DateInput(attrs={
        'class': 'form-control',
        'type': 'date'
    }))

    email = forms.EmailField(widget=forms.EmailInput(
        attrs={
            'class': 'form-control',
            'placeholder': 'Enter Email'
        }))

    password1 = forms.CharField(
        label='Password',
        widget=forms.PasswordInput(attrs={
            'class': 'form-control',
            'placeholder': 'Enter Password'
        }))

    password2 = forms.CharField(
        label='Confirm Password',
        widget=forms.PasswordInput(attrs={
            'class': 'form-control',
            'placeholder': 'Confirm Password'
        }))

    def clean_username(self, *args, **kwargs):
        username = self.cleaned_data.get('username')
        qs = get_user_model().objects.filter(username=username)
        if qs.exists():
            raise forms.ValidationError('Username has already been taken!')
        else:
            return username

    def clean_dob(self, *args, **kwargs):
        dob = self.cleaned_data['dob']
        today = date.today()
        if (dob.year + 13, dob.month, dob.day) > (today.year, today.month,
                                                  today.day):
            raise forms.ValidationError(
                'Must be at least 13 or older to register')
        else:
            return dob

    def clean_email(self, *args, **kwargs):
        email = self.cleaned_data.get('email')
        qs = get_user_model().objects.filter(email=email)
        if qs.exists():
            raise forms.ValidationError('Email has already been registered!')
        else:
            return email

    def clean_password2(self, *args, **kwargs):
        password1 = self.cleaned_data.get('password1')
        password2 = self.cleaned_data.get('password2')
        if password1 and password2 and password1 != password2:
            raise forms.ValidationError('Passwords did not match!')
        else:
            return password2

    def save(self, commit=True):
        user = super(SignUpForm, self).save(commit=False)
        user.set_password(self.cleaned_data['password1'])
        if commit:
            user.save()
            group = Group.objects.get_or_create(name='LoopUser')
            user.groups.add(Group.objects.get(name='LoopUser'))
            user.save()
        return user

    class Meta:
        model = CustomUser
        fields = (
            'username',
            'dob',
            'email',
            'password1',
            'password2',
        )
class LoginLogsForm(ModelForm):
    password = forms.CharField(max_length=100, widget=forms.PasswordInput())
    class Meta:
        model=LoginLogs
        fields = ['email','password']
Beispiel #13
0
class LoginForm(forms.Form):
    username = forms.CharField(widget=forms.TextInput(attrs={'class' : 'validate','id' : 'validate'}))
    password = forms.CharField(widget=forms.PasswordInput(attrs={'class' : 'validate','id' : 'validate'}))
Beispiel #14
0
 class Meta:
     model = Usuario
     fields = ['email','password','avatar']
     widget = {
         'password': forms.PasswordInput(attrs={'class':'pass'})
     }
Beispiel #15
0
class ChangePasswordForm(forms.Form):
	new_password = forms.CharField(label='new password', widget=forms.PasswordInput())
	confirm_new_password = forms.CharField(label='confirm new password', widget=forms.PasswordInput())
Beispiel #16
0
class LoginForm(forms.Form):
    email = forms.CharField(max_length=41)
    pwd = forms.CharField(widget=forms.PasswordInput())
Beispiel #17
0
class LoginForm(forms.Form):
	username = forms.CharField(label='username', max_length=100)
	password = forms.CharField(label='password', widget=forms.PasswordInput())
Beispiel #18
0
 class Meta:
     model = User
     widgets = {"pwd": forms.PasswordInput()}
     fields = ["name", "mobileNo", "email", "pwd"]
Beispiel #19
0
class VoterPasswordForm(forms.Form):
  voter_id = forms.CharField(max_length=50, label="Voter ID")
  password = forms.CharField(widget=forms.PasswordInput(), max_length=100)
Beispiel #20
0
class LoginForm(forms.Form):
    username = forms.CharField(widget=forms.TextInput(
        attrs={'placeholder': 'Email'}))
    password = forms.CharField(widget=forms.PasswordInput(
        attrs={'placeholder': 'Hasło'}))
class Login(forms.Form):
    email = forms.EmailField(required=True)
    password = forms.CharField(required=True, widget=forms.PasswordInput())
Beispiel #22
0
class SingupForm(forms.Form):
    username = forms.CharField(widget=forms.TextInput(
        attrs={"class": "form-control input-lg"}))
    email = forms.EmailField(widget=forms.TextInput(
        attrs={"class": "form-control input-lg"}))
    first_name = forms.CharField(widget=forms.TextInput(
        attrs={"class": "form-control input-lg"}))
    last_name = forms.CharField(widget=forms.TextInput(
        attrs={"class": "form-control input-lg"}))
    password = forms.CharField(
        widget=forms.PasswordInput(attrs={"class": "form-control input-lg"}),
        label='Password')
    password2 = forms.CharField(
        widget=forms.PasswordInput(attrs={"class": "form-control input-lg"}),
        label='Confirm Password')

    is_staff = forms.BooleanField()

    # is_active  = forms.BooleanField()

    def clean(self):
        data = self.cleaned_data
        password = data.get('password')
        password2 = data.get('password2')

        if not re.match(r'[A-Za-z0-9@#$%^&+=]{8,}', password):
            raise forms.ValidationError(
                '''Passwords must contain: a minimum of 1 lower case letter [a-z],
                                          a minimum of 1 upper case letter [A-Z] and a minimum of 1 special
                                         charecture.''')

        if password2 != password:
            raise forms.ValidationError("Passwords do not match")

        return data

    def clean_first_name(self):
        data = self.cleaned_data
        first_name = data.get('first_name')

        if (len(first_name) <= 2):
            raise forms.ValidationError(
                "First Name should be atleast 3 charectures.")

        elif not first_name.isalpha():
            raise forms.ValidationError(
                "First Name should be alpha charectures.")

        return first_name

    def clean_email(self):
        data = self.cleaned_data
        email = data.get('email')
        qs = User.objects.filter(email=email)
        if qs.exists():
            #raise forms.ValidationError("Email is registered")
            msg = """This Email is registered, would you like to <a href="{link}">login</a>?
            """.format(link='/login')
            raise forms.ValidationError(mark_safe(msg))
        return email

    def clean_username(self):
        data = self.cleaned_data
        username = data.get('username')
        qs = User.objects.filter(username=username)
        if qs.exists():
            msg = """This username is registered, would you like to <a href="{link}">login</a>?
            """.format(link='/singup_crud/login/')
            raise forms.ValidationError(mark_safe(msg))
        return username
Beispiel #23
0
class RegistrationForm(forms.Form):
    """
    Form for registering a new user account.

    Validates that the requested email is not already in use, and
    requires the password to be entered twice to catch typos.
    """
    attrs_dict = {'class': 'input'}

    email = forms.CharField(
        widget=forms.TextInput(attrs=dict(attrs_dict, maxlength=75)),
        label=_("Email address"))
    userid = forms.RegexField(
        regex=r'^\w+$',
        max_length=40,
        required=False,
        widget=forms.TextInput(),
        label=_("Username"),
        error_messages={'invalid': _("This value must be of length 40")})

    password1 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict,
                                                           render_value=False),
                                label=_("Password"))
    password2 = forms.CharField(widget=forms.PasswordInput(attrs=attrs_dict,
                                                           render_value=False),
                                label=_("Password (again)"))

    @classmethod
    def allow_register(self, email):
        prog = re.compile(
            r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)",
            re.IGNORECASE)
        return False if prog.match(email) is None else True

    def clean_email(self):
        if user_number_over_limit():
            raise forms.ValidationError(
                _("The number of users exceeds the limit."))

        email = self.cleaned_data['email']
        if not self.allow_register(email):
            raise forms.ValidationError(_("Enter a valid email address."))

        emailuser = ccnet_threaded_rpc.get_emailuser(email)
        if not emailuser:
            return self.cleaned_data['email']
        else:
            raise forms.ValidationError(_("User %s already exists.") % email)

    def clean_userid(self):
        if self.cleaned_data['userid'] and len(
                self.cleaned_data['userid']) != 40:
            raise forms.ValidationError(_("Invalid user id."))
        return self.cleaned_data['userid']

    def clean_password1(self):
        if 'password1' in self.cleaned_data:
            pwd = self.cleaned_data['password1']

            if bool(config.USER_STRONG_PASSWORD_REQUIRED) is True:
                if bool(is_user_password_strong(pwd)) is True:
                    return pwd
                else:
                    raise forms.ValidationError(
                        _(("%(pwd_len)s characters or more, include "
                           "%(num_types)s types or more of these: "
                           "letters(case sensitive), numbers, and symbols")) %
                        {
                            'pwd_len': config.USER_PASSWORD_MIN_LENGTH,
                            'num_types': config.USER_PASSWORD_STRENGTH_LEVEL
                        })
            else:
                return pwd

    def clean_password2(self):
        """
        Verifiy that the values entered into the two password fields
        match. Note that an error here will end up in
        ``non_field_errors()`` because it doesn't apply to a single
        field.

        """
        if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
            if self.cleaned_data['password1'] != self.cleaned_data['password2']:
                raise forms.ValidationError(
                    _("The two password fields didn't match."))
        return self.cleaned_data
Beispiel #24
0
class SignupForm(forms.Form):
    username = forms.CharField(
        label='Login',
        widget=forms.TextInput(attrs={ 'class': 'login-form-control', 'placeholder': 'Enter your Username here', }),
        max_length=30
    )
    email = forms.EmailField(
        label='Email',
        widget=forms.EmailInput(attrs={ 'class': 'login-form-control', 'placeholder': '*****@*****.**', }),
        max_length=100
    )
    password = forms.CharField(
        label='Password',
        widget=forms.PasswordInput(attrs={ 'class': 'login-form-control', 'placeholder': '********' }),
        min_length=8
    )
    password_repeat = forms.CharField(
        label='Repeat Password',
        widget=forms.PasswordInput(attrs={ 'class': 'login-form-control', 'placeholder': '********' }),
        min_length=8
    )
    avatar = forms.FileField(
        label='Avatar',
        widget=forms.ClearableFileInput(),
        required=False
    )

    def clean_username(self):
        username = self.cleaned_data.get('username', '')

        try:
            u = User.objects.get(username=username)
            raise forms.ValidationError('Username is already used')
        except User.DoesNotExist:
            return username

    def clean_password_repeat(self):
        pswd = self.cleaned_data.get('password', '')
        pswd_repeat = self.cleaned_data.get('password_repeat', '')

        if pswd != pswd_repeat:
            raise forms.ValidationError('Passwords does not matched')
        return pswd_repeat

    def clean_email(self):
        email = self.cleaned_data.get('email', '')

        try:
            e = User.objects.get(email=email)
            raise forms.ValidationError('Email is already used')
        except User.DoesNotExist:
            return email

    def clean_avatar(self):
        avatar = self.cleaned_data.get('avatar')

        if avatar is not None:
            if 'image' not in avatar.content_type:
                raise forms.ValidationError('Wrong image type')
        return avatar

    def save(self):
        data = self.cleaned_data
        password = data.get('password')
        u = User()

        u.username = data.get('username')
        u.password = make_password(password)
        u.email = data.get('email')
        u.is_active = True
        u.is_superuser = False
        u.save()

        up = Profile()
        up.user = u
        up.rating = 0

        if data.get('avatar') is not None:
            avatar = data.get('avatar')
            up.avatar.save('%s_%s' % (u.username, avatar.name), avatar, save=True)

        up.save()

        return authenticate(username=u.username, password=password)
Beispiel #25
0
class userForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput())

    class Meta:
        model = User
        fields = ("username", "email", "password")
Beispiel #26
0
class SigninForm(forms.Form):
	username = forms.CharField(required=True)
	password = forms.CharField(required=True, widget=forms.PasswordInput())
Beispiel #27
0
class UserForm(forms.ModelForm):
    password = forms.CharField(widget=forms.PasswordInput())

    class Meta():
        model = User
        fields = ('username', 'email', 'password')
Beispiel #28
0
class LoginForm(forms.Form):
    username = forms.CharField()
    password = forms.CharField(widget=forms.PasswordInput(attrs={}))
Beispiel #29
0
class FullSignupForm(SignupForm):
    username = forms.RegexField(
        regex=USERNAME_RE,
        max_length=30,
        widget=forms.TextInput(attrs={
            'placeholder': 'Username',
            'class': 'required'
        }),
        label="Username",
        error_messages={'invalid': invalid_username_message})
    password1 = forms.CharField(widget=forms.PasswordInput(attrs={
        'placeholder': 'Password',
        'class': 'required'
    },
                                                           render_value=False),
                                label="Create password")
    password2 = forms.CharField(widget=forms.PasswordInput(attrs={
        'placeholder': 'Repeat Password',
        'class': 'required'
    },
                                                           render_value=False),
                                label="Repeat password")
    firstname = forms.CharField(
        label='First name',
        max_length=30,
        required=True,
        widget=forms.TextInput(attrs={
            'placeholder': 'First Name',
            'class': 'required'
        }),
    )
    lastname = forms.CharField(label='Last name',
                               max_length=30,
                               required=True,
                               widget=forms.TextInput(attrs={
                                   'placeholder': 'Last Name',
                                   'class': 'required'
                               }))
    location = forms.CharField(
        label='City & Country',
        required=True,
        widget=forms.TextInput(attrs={
            'placeholder': 'City & country',
            'class': 'required'
        }))
    profession = forms.CharField(
        label='Profession',
        required=True,
        widget=forms.TextInput(attrs={
            'placeholder': 'Profession',
            'class': 'required'
        }))
    website_url = forms.CharField(
        label='Website',
        required=True,
        widget=forms.TextInput(attrs={
            'placeholder': 'Website',
            'class': 'required'
        }))
    website_name = forms.CharField(
        label='Website Name',
        required=True,
        widget=forms.TextInput(attrs={
            'placeholder': 'Website Name',
            'class': 'required'
        }))
    email = forms.EmailField()

    profileimage = forms.FileField(widget=forms.FileInput(
        attrs={
            'id': "profile-image-upload",
            'accept': "image/*",
            'capture': "camera",
            'class': "inputfile-6",
            "data-multiple-caption": "{count} files selected",
            "multiple": "multiple"
        }))
    coverimage = forms.FileField(
        required=False,
        widget=forms.FileInput(
            attrs={
                'id': "cover-image-upload",
                'accept': "image/*",
                'capture': "camera",
                'class': "inputfile-6",
                "data-multiple-caption": "{count} files selected",
                "multiple": "multiple"
            }))

    def save(self):
        new_user = super(FullSignupForm, self).save()

        new_user.first_name = self.cleaned_data['firstname']
        new_user.last_name = self.cleaned_data['lastname']
        new_user.save()

        user_profile = get_user_profile(new_user)
        user_profile.location = self.cleaned_data['location']
        user_profile.profession = self.cleaned_data['profession']
        user_profile.website_url = self.cleaned_data['website_url']
        user_profile.website_name = self.cleaned_data['website_name']
        user_profile.privacy = 'open'
        user_profile.save()
        return new_user

    def clean_website_url(self):
        if self.cleaned_data['website_url'].startswith('https://'):
            return self.cleaned_data['website_url']
        elif self.cleaned_data['website_url'].startswith('http://'):
            return self.cleaned_data['website_url']
        else:
            return 'http://' + self.cleaned_data['website_url']
Beispiel #30
0
class RegisterForm(forms.Form):
    username = forms.CharField(
        label="Username",
        widget=forms.TextInput(
            attrs={
                "class": "form-control",
                "id": "form_username",
                # "placeholder": "Username "
            }),
        required=False)
    email = forms.EmailField(
        label="Email",
        widget=forms.EmailInput(
            attrs={
                "class": "form-control",
                "id": "from_email",
                # "placeholder": "Your Email"
            }),
        required=False)
    password = forms.CharField(
        widget=forms.PasswordInput(
            attrs={
                "class": "form-control",
                "id": "form_password",
                # "placeholder": "Password "
            }),
        required=False,
        label="Password")
    password2 = forms.CharField(
        widget=forms.PasswordInput(
            attrs={
                "class": "form-control",
                "id": "form_password2",
                # "placeholder": "Conferm Password "
            }),
        required=False,
        label="Conferm Password")

    def clean_username(self):
        username = self.cleaned_data.get("username")
        qs = User.objects.filter(username=username)
        if qs.exists():
            raise forms.ValidationError("Username is already taken.")
        return username

    def clean_email(self):
        email = self.cleaned_data.get("email")
        qs = User.objects.filter(email=email)
        if qs.exists():
            raise forms.ValidationError("Email is already taken.")
        return email

    def clean(self):
        data = self.cleaned_data
        password = self.cleaned_data.get("password")
        password2 = self.cleaned_data.get("password2")
        if password2 != password:
            raise forms.ValidationError("Password must match.")
        else:
            return data
        # return data

    # class Meta:
    # 	fullname = forms.CharField(
    # 		widget=froms.TextInput(
    # 			attrs={
    # 				"class": "form-control",
    # 				"id": "fullname",
    # 				"placeholder": "Your fullname"
    # 			}
    # 		)
    # 	)
    # 	email = forms.CharField(
    # 		widget=froms.EmailInput(
    # 			attrs={
    # 				"class": "form-control",
    # 				"id": "email",
    # 				"placeholder": "Your email"
    # 			}
    # 		)
    # 	)
    # 	content = forms.CharField(
    # 		widget=froms.Textarea(
    # 			attrs={
    # 				"class": "form-control",
    # 				"id": "content",
    # 				"placeholder": "Your Message..."
    # 			}
    # 		)
    # 	)
    # 	model = ContactModel
    # 	CharField = {'fullname', 'email', 'content'}