class RegisterForm(Form): username = TextField("Username", validators=[DataRequired()]) email = EmailField("Email", validators=[DataRequired(), EmailValidator()]) email_verify = EmailField( "Verify Email", validators=[DataRequired(), EqualTo("email")]) password = PasswordField( "Password", validators=[DataRequired(), LengthValidator(min=8)]) password_verify = PasswordField( "Verify Password", validators=[DataRequired(), EqualTo("password")])
class SignupForm(Form): """ Sign up form (registration to jarr). """ login = TextField( lazy_gettext("Login"), [validators.Required(lazy_gettext("Please enter your login"))]) password = PasswordField(lazy_gettext("Password"), [ validators.Required(lazy_gettext("Please enter a password.")), validators.Length(min=6, max=100) ]) password_conf = PasswordField( lazy_gettext("Password"), [validators.Required(lazy_gettext("Confirm the password."))]) email = EmailField(lazy_gettext("Email"), [ validators.Length(min=6, max=35), validators.Required(lazy_gettext("Please enter your email address.")) ]) # recaptcha = RecaptchaField() submit = SubmitField(lazy_gettext("Sign up")) def validate(self): ucontr = UserController() validated = super().validate() if ucontr.read(login=self.login.data).count(): self.login.errors.append('Login already taken') validated = False if self.password.data != self.password_conf.data: self.password_conf.errors.append("Passwords don't match") validated = False return validated
class SignupForm(Form): next = HiddenField() nickname = TextField(u'昵称', [Required()], description=u'朋友们将看到你的名字') email = EmailField(u'邮箱', [Required(), Email()], description=u'您在本站的唯一身份标识') password = PasswordField( u'密码', [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)], description=u'至少 %s 字符' % PASSWORD_LEN_MIN) agree = BooleanField(u'我同意 ' + Markup(u'<a target="blank" href="/terms">站点规范</a>'), [Required()], default=True) submit = SubmitField(u'注册') def validate_email(self, field): if is_email_taken(field.data): raise ValidationError(u'该Email地址已经注册') def save(self): user = User(self.email.data) self.populate_obj(user) db.session.add(user) db.session.commit() db.session.refresh(user) return user
class ProfileForm(Form): """ Edit user information. """ nickname = TextField(lazy_gettext("Nickname"), [validators.Required(lazy_gettext("Please enter your nickname."))]) email = EmailField(lazy_gettext("Email"), [validators.Length(min=6, max=35), validators.Required(lazy_gettext("Please enter your email."))]) password = PasswordField(lazy_gettext("Password")) password_conf = PasswordField(lazy_gettext("Password Confirmation")) refresh_rate = IntegerField(lazy_gettext("Feeds refresh frequency " "(in minutes)"), default=60) submit = SubmitField(lazy_gettext("Save")) def validate(self): validated = super(ProfileForm, self).validate() if self.password.data != self.password_conf.data: message = lazy_gettext("Passwords aren't the same.") self.password.errors.append(message) self.password_conf.errors.append(message) validated = False if self.nickname.data != User.make_valid_nickname(self.nickname.data): self.nickname.errors.append(lazy_gettext('This nickname has ' 'invalid characters. Please use letters, numbers, dots and' ' underscores only.')) validated = False return validated
class SigninForm(RedirectForm): """ Sign in form (connection to jarr). """ email = EmailField("Email", [validators.Length(min=6, max=35), validators.Required(lazy_gettext("Please enter your email address."))]) password = PasswordField(lazy_gettext('Password'), [validators.Required(lazy_gettext("Please enter a password.")), validators.Length(min=6, max=100)]) submit = SubmitField(lazy_gettext("Log In")) def validate(self): if not super(SigninForm, self).validate(): return False user = User.query.filter(User.email == self.email.data).first() if user and user.check_password(self.password.data) \ and user.activation_key == "": return True elif user and user.activation_key != "": flash(lazy_gettext('Account not confirmed'), 'danger') return False else: flash(lazy_gettext('Invalid email or password'), 'danger') return False
class SignupForm(Form): next = HiddenField() email = EmailField(_('Email'), [Required(), Email()], description=_("What's your email address?")) name = TextField( _('Choose your username'), [Required(), Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)]) location = TextField(_('Location'), [Required()]) agree = BooleanField( _('I agree ') + Markup( _('to the ') + '<a target="blank" href="/terms">' + _('Terms of Service') + '</a>'), [Optional()]) submit = SubmitField('Sign up') def validate_name(self, field): if User.query.filter_by(name=field.data).first() is not None: raise ValidationError(_('This username is taken')) def validate_email(self, field): if User.query.filter_by(email=field.data).first() is not None: raise ValidationError(_('This email is taken')) def validate_location(self, field): if field.data not in COUNTRY_CODES.values(): raise ValidationError(_('Please choose a valid location.')) def signup(self): user = User() self.location.data = get_country_code(self.location.data) self.populate_obj(user) user.password = uuid.uuid4().hex db.session.add(user) db.session.commit() return user
class SignUpForm(Form): """ A simple signup form for front end. """ username = TextField( 'Username', validators=[ DataRequired(), Length(min=3, max=20), Regexp(r'([a-zA-Z_0-9])[\.$0]*') ], description='English Characters Only.', ) email = EmailField('Email', validators=[DataRequired(), Email()]) password = PasswordField('Password', validators=[DataRequired()]) def validate_username(self, field): user = models.User.query.filter( models.User.username == field.data.lower()).first() if user: raise ValueError('This name has been registered.') def validate_email(self, field): user = models.User.query.filter( models.User.email == field.data.lower()).first() if user: raise ValueError('This name has been registered.')
class SignupForm(Form): next = HiddenField() email = EmailField(_('Email'), [Required(), Email()], description=_("What's your email address?")) password = PasswordField( _('Password'), [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)], description=_('%(minChar)s characters or more! Be tricky.', minChar=PASSWORD_LEN_MIN)) name = TextField( _('Choose your username'), [Required(), Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)], description=_("Don't worry. you can change it later.")) agree = BooleanField( _('Agree to the ') + Markup('<a target="blank" href="/terms">' + _('Terms of Service') + '</a>'), [Required()]) submit = SubmitField('Sign up') def validate_name(self, field): if User.query.filter_by(name=field.data).first() is not None: raise ValidationError(_('This username is taken')) def validate_email(self, field): if User.query.filter_by(email=field.data).first() is not None: raise ValidationError(_('This email is taken')) def signup(self): user = User() self.populate_obj(user) db.session.add(user) db.session.commit() return user
class userForm(Form): choices = [ ("subscriber", u"关注者"), ("editor", u"编辑"), ("administrator", u"管理员"), ] user_id = HiddenField() username = StringField(u"用户名*", validators=[InputRequired()], description=u"此用户名将作为用户登录时所用的名称.<br>请不要与系统中现有的用户名重复.") email = EmailField(u"电子邮件*", validators=[InputRequired()], description=u"电子邮箱地址将作为此用户的主要联系方式.<br>请不要与系统中现有的电子邮箱地址重复.") screenName = StringField(u"用户昵称", description=u"用户昵称可以与用户名不同, 用于前台显示.<br>如果你将此项留空, 将默认使用用户名.") password = PasswordField(u"用户密码*", validators=[InputRequired(), EqualTo("password2", message="密码不相同")], description=u"为此用户分配一个密码.<br>建议使用特殊字符与字母、数字的混编样式,以增加系统安全性.") password2 = PasswordField(u"用户密码确认*", validators=[InputRequired()], description=u"请确认你的密码, 与上面输入的密码保持一致.") url = StringField(u"用户主页", description=u"此用户的个人主页地址, 请用 http:// 开头.") group = SelectField(u"用户组", choices=choices, default=["subscriber"], description=u"不同的用户组拥有不同的权限.<br>具体的权限分配表请<a href=\"#\">参考这里</a>.") submit = SubmitField(u"新增用户") def __init__(self, user=None): super(userForm, self).__init__() if user: self.user_id.data = user.id self.username.data = user.username self.email.data = user.email self.screenName.data = user.screenName self.url.data = user.url self.group.data = user.group
class CreateProfileForm(Form): openid = HiddenField() name = TextField( _('Choose your username'), [Required(), Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)], description=_("Don't worry. you can change it later.")) email = EmailField(_('Email'), [Required(), Email()], description=_("What's your email address?")) password = PasswordField( _('Password'), [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)], description=_('%(minChar)s characters or more! Be tricky.', minChar=PASSWORD_LEN_MIN)) submit = SubmitField(_('Create Profile')) def validate_name(self, field): if User.query.filter_by(name=field.data).first() is not None: raise ValidationError(_('This username is taken.')) def validate_email(self, field): if User.query.filter_by(email=field.data).first() is not None: raise ValidationError(_('This email is taken.')) def create_profile(self): user = User() self.populate_obj(user) db.session.add(user) db.session.commit()
class SignupForm(Form): next = HiddenField() name = TextField( 'Username', [Required(), Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)], ) password = PasswordField( 'Password', [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)], ) password_again = PasswordField( 'Password again', [ Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX), EqualTo('password') ], ) email = EmailField( 'Email', [Required(), Email()], ) submit = SubmitField('Sign up') def validate_name(self, field): if User.query.filter_by(name=field.data).first() is not None: raise ValidationError, gettext('This username is taken') def validate_email(self, field): if User.query.filter_by(email=field.data).first() is not None: raise ValidationError, gettext('This email is taken')
class LoginForm(RedirectForm): """ Form for Login """ emailaddress = EmailField("Emailadres", validators=[Required()]) password = PasswordField("Wachtwoord", validators=[Required()]) remember_me = BooleanField("Blijf ingelogd", default=False)
class UserRegistration(Form): username = TextField( "Username", validators=[ Not(MatchesRegex("[^0-9a-zA-Z\-_]"), message= "Your username contains invalid characters. Only use alphanumeric characters, dashes and underscores." ), Not(UsernameExists(), message="That username already exists."), Length( min=3, max=80, message= "You have to enter a username of 3 to 80 characters length.") ]) password = PasswordField( "Password", validators=[ Length(min=8, message="Please enter a password of at least 8 characters.") ]) password2 = PasswordField( "Password, again", validators=[EqualTo("password", "Passwords do not match.")]) email = EmailField( "Email", validators=[ Not(EmailExists(), message="That email address is already in use."), Email(message="The email address you entered is invalid.") ]) captcha = RecaptchaField()
class SignupForm(Form): next = HiddenField() email = EmailField(u'Email', [Required(), Email()], description=u"What's your email address?") password = PasswordField( u'Password', [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)], description=u'%s characters or more! Be tricky.' % PASSWORD_LEN_MIN) name = TextField( u'Choose your username', [Required(), Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX)], description=u"Don't worry. you can change it later.") agree = BooleanField( u'Agree to the ' + Markup('<a target="blank" href="/terms">' + 'Terms of Service</a>'), [Required()]) submit = SubmitField('Sign up') def validate_name(self, field): if User.query.filter_by(name=field.data).first() is not None: raise ValidationError(u'This username is taken') def validate_email(self, field): if User.query.filter_by(email=field.data).first() is not None: raise ValidationError(u'This email is taken')
class AddEmailForm(Form): email = EmailField("E-Mail Address", validators = [ EmailValidator(message = "The email address you entered is invalid."), Not(EmailExists(), message = "This email address is already in use by one of the users, possibly you!?")]) default = BooleanField("Set as default", default = False) gravatar = BooleanField("Use for gravatar", default = False) submit = SubmitField("Add")
class RegisterForm(Form): username = TextField( label=_('Username'), validators=[ Required() ] ) email = EmailField( label=_('Email address'), validators=[ Required(), Email("That doesn't look like an email.") ] ) password = PasswordField( label=_('Password'), validators=[ Required(), Length( min=PASSWORD_LEN_MIN, max=PASSWORD_LEN_MAX, ) ] ) password_again = PasswordField( label=_('Repeat Password'), validators=[ Required(), EqualTo('password_again', message=_('Passwords must match.')) ] ) #recaptcha = RecaptchaField() submit = SubmitField(_('Create account'))
class NewJudge(Form): name = TextField("Name", [validators.Required("Please enter your name.")]) email = EmailField("Email", [ validators.Required("Please enter your email address."), validators.Email("Please enter a valid email address.") ]) password = PasswordField('Password', [validators.Required("Please enter a password.")]) pwdcheck = PasswordField( 'Re-type Password', [validators.Required("Please re-type your password.")]) def validate(self): if not Form.validate(self): return False if self.pwdcheck.data != self.password.data: self.password.errors.append( "Please retype your password - they didn't match") return False checkmember = Member.query.filter_by( email=self.email.data.lower()).first() checkjudge = Judge.query.filter_by( email=self.email.data.lower()).first() if checkmember or checkjudge: # check if email is already taken self.email.errors.append("That email is already taken") return False judge = Judge(self.name.data, self.email.data.lower(), self.password.data) db.session.commit() return True
class SignupForm(BaseForm): username = TextField( _('Username'), validators=[ DataRequired(), Length(min=3, max=20), Regexp(r'^[a-z0-9A-Z]+$') ], description=_('English Characters Only.'), ) email = EmailField( _('Email'), validators=[DataRequired(), Email()] ) password = PasswordField( _('Password'), validators=[DataRequired()] ) def validate_username(self, field): data = field.data.lower() if data in RESERVED_WORDS: raise ValueError(_('This name is a reserved name.')) if data in current_app.config.get('RESERVED_WORDS', []): raise ValueError(_('This name is a reserved name.')) if Account.query.filter_by(username=data).count(): raise ValueError(_('This name has been registered.')) def validate_email(self, field): if Account.query.filter_by(email=field.data.lower()).count(): raise ValueError(_('This email has been registered.')) def save(self, role=None): user = Account(**self.data) if role: user.role = role user.save() return user
class ProfileForm(Form): multipart = True next = HiddenField() email = EmailField(u'Email', [Required(), Email()]) # Don't use the same name as model because we are going to use populate_obj(). avatar_file = FileField(u"Avatar", [Optional()]) sex_code = RadioField(u"Sex", [AnyOf([str(val) for val in SEX_TYPE.keys()])], choices=[(str(val), label) for val, label in SEX_TYPE.items()]) age = IntegerField(u'Age', [Optional(), NumberRange(AGE_MIN, AGE_MAX)]) phone = TelField(u'Phone', [Length(max=64)]) url = URLField(u'URL', [Optional(), URL()]) deposit = DecimalField( u'Deposit', [Optional(), NumberRange(DEPOSIT_MIN, DEPOSIT_MAX)]) location = TextField(u'Location', [Length(max=64)]) bio = TextAreaField(u'Bio', [Length(max=1024)]) submit = SubmitField(u'Save') def validate_name(form, field): user = User.get_by_id(current_user.id) if not user.check_name(field.data): raise ValidationError("Please pick another name.") def validate_avatar_file(form, field): if field.data and not allowed_file(field.data.filename): raise ValidationError("Please upload files with extensions: %s" % "/".join(ALLOWED_AVATAR_EXTENSIONS))
class RecoverPasswordForm(Form): email = EmailField( label=_('Your email'), validators=[ Email(message=_("That doesn't look like an email.")) ] ) submit = SubmitField(_('Send instructions'))
class ProfileForm(Form): next = HiddenField() name = TextField( label = _("Username"), validators = [ Required(), Length(USERNAME_LEN_MIN, USERNAME_LEN_MAX), ], description = u"Combination of letters/digits/underscore, at least %s characters." % USERNAME_LEN_MIN, ) email = EmailField( label = _('Email'), validators = [Email()], ) created_time = DateField( label = _('Created time'), ) role_id = RadioField( label = "Role", validators = [AnyOf([str(val) for val in USER_ROLE.keys()])], choices = [(str(val), label) for val, label in USER_ROLE.items()], ) status_id = RadioField( label = "Status", validators = [AnyOf([str(val) for val in USER_STATUS.keys()])], choices = [(str(val), label) for val, label in USER_STATUS.items()], ) real_name = TextField( label = _('Real name'), validators = [ Length(REALNAME_LEN_MIN, REALNAME_LEN_MAX), ] ) age = IntegerField( label = _('Age'), validators = [NumberRange(AGE_MIN, AGE_MAX)], ) phone = TelField( label = _('Phone'), ) url = URLField( label = _('URL'), validators = [URL()], ) deposit = DecimalField( label = _('Deposit'), validators = [NumberRange(DEPOSIT_MIN, DEPOSIT_MAX)], ) location = TextField( label = _('Location'), validators = [Length(max=50)] ) bio = TextAreaField( label = _('Bio'), validators = [Length(max=1024)] ) submit = SubmitField(_('Save'))
class ContactForm(Form): """Contact form""" name = TextField(label="Name", validators=[Length(max=35), Required()]) email = EmailField(label="Email address", validators=[Length(min=6, max=120), Email()]) message = TextAreaField(label="Message", validators=[Length(max=1000), Required()]) recaptcha = RecaptchaField(label="reCAPTCHA")
class RegistrationForm(mixin_class, Form): email = EmailField(label=_l(u"Your email address"), validators=[required(), email()]) coming_on_oct_3 = BooleanField( label=_l(u"Will you come on Oct. 3th? (Thursday)")) coming_on_oct_4 = BooleanField( label=_l(u"Will you come on Oct. 4th? (Friday)")) coming_on_oct_5 = BooleanField( label=_l(u"Will you come on Oct. 5th? (Saturday)"))
class LoginForm(Form): email = EmailField( 'Email', [validators.Required("Please enter your email address.")]) password = PasswordField( 'Password', [validators.Required("Please enter your password.")]) def validate(self): if not Form.validate(self): return False return True
class ContactForm(Form): name = TextField("Name", [validators.Required("Please enter your name.")]) email = EmailField("Email", [ validators.Required("Please enter your email address."), validators.Email("Please enter your email address.") ]) subject = TextField("Subject", [validators.Required("Please enter a subject.")]) message = TextAreaField("Message", [validators.Required("Please enter a message.")]) submit = SubmitField("Send")
class ProfileForm(Form): multipart = True next = HiddenField() email = EmailField(_('Email'), [Required(), Email()]) avatar_file = FileField(_("Avatar"), [Optional()]) gender_code = RadioField(_("Gender"), [AnyOf([str(val) for val in GENDER_TYPE.keys()])], choices=[(str(val), label) for val, label in GENDER_TYPE.items()]) bio = TextAreaField(_('Bio'), [Length(max=1024)]) submit = SubmitField(_('Save')) def validate_name(form, field): user = User.get_by_id(current_user.id) if not user.check_name(field.data): raise ValidationError(_("Please pick another name.")) def validate_avatar_file(form, field): if field.data and not allowed_file(field.data.filename): raise ValidationError( _("Please only upload files with extensions:") + " %s" % "/".join(ALLOWED_AVATAR_EXTENSIONS)) def create_profile(self, request, user): if self.avatar_file.data: upload_file = request.files[self.avatar_file.name] if upload_file and allowed_file(upload_file.filename): # Don't trust any input, we use a random string as filename. # or use secure_filename: # http://flask.pocoo.org/docs/patterns/fileuploads/ user_upload_dir = os.path.join( current_app.config['UPLOAD_FOLDER'], "user_%s" % user.id) current_app.logger.debug(user_upload_dir) make_dir(user_upload_dir) root, ext = os.path.splitext(upload_file.filename) today = datetime.now().strftime('_%Y-%m-%d') # Hash file content as filename. hash_filename = hashlib.sha1( upload_file.read()).hexdigest() + "_" + today + ext user.avatar = hash_filename avatar_ab_path = os.path.join(user_upload_dir, user.avatar) # Reset file curso since we used read() upload_file.seek(0) upload_file.save(avatar_ab_path) self.populate_obj(user) self.populate_obj(user.user_detail) db.session.add(user) db.session.commit()
class RegistrationForm(Form): username = TextField("Username", validators=[ Required(), Regexp("[0-9a-zA-Z\-_]", message = "The username contains invalid characters. Only use alphanumeric characters, dashes and underscores."), Not(UsernameExists(), message = "That username already exists."), Length(min = 3, max = 32, message="You have to enter a username of 3 to 32 characters length.")]) password = PasswordField("Password", validators=[Length(min = 6, message = "Please enter a password of at least 6 characters.")]) password2 = PasswordField("Password, again", validators=[EqualTo("password", "Passwords do not match.")]) email = EmailField("Email Address", validators=[ Required(), Not(EmailExists(), message = "That email address is already in use."), EmailValidator(message = "The email address you entered is invalid.")])
class ContactForm(Form): name = TextField(_('Name'), validators=[Required()]) subject = TextField(_('Subject'), validators=[Required()]) email = EmailField(_('Email'), validators=[Required()], description=u"What's your email address?") message = TextAreaField(_('Message'), validators=[Required()]) submit = SubmitField(u'Send')
class LoginForm(Form): """A basic login form. Includes an email field and a password field. """ email = EmailField('Email Address', [Required(), Email()]) password = PasswordField('Password', [Required()]) def validate(self): rv = Form.validate(self) if not rv: return False self.email.data = self.email.data.lower() return True
class SignupForm(Form): name = TextField('Username', [Required()]) email = EmailField('Email', [Required()]) full_name = TextField('Full name') password = PasswordField('Password', [Required()]) def validate_name(form, field): user = users.get_user(field.data) if user: raise ValidationError('This username is already taken') def validate_password(form, field): if len(field.data) < 4: raise ValidationError('The password is too short')