class EditMyAccountForm(Form): username = TextField(_(u"用户名:"), validators=[ required(_(u"请输入用户名")), is_legal_name]) email = TextField(_(u"邮箱地址:"), validators=[ required(message=_(u"请输入邮箱地址")), email(message=_(u"请输入有效的邮箱地址"))]) email_alerts = BooleanField(_(u"开启邮件提醒")) status = BooleanField(_(u"账号状态")) submit = SubmitField(_(u"保存")) def __init__(self, user, *args, **kwargs): self.user = user kwargs['obj'] = self.user super(EditMyAccountForm, self).__init__(*args, **kwargs) def validate_username(self, field): user = User.query.filter(db.and_( User.username.like(field.data), db.not_(User.id == self.user.id))).first() if user: raise ValidationError(gettext(u"用户名已经存在")) def validate_email(self, field): user = User.query.filter(db.and_( User.email.like(field.data), db.not_(User.id == self.user.id))).first() if user: raise ValidationError(gettext(u"邮箱地址已经存在"))
class SignupForm(BaseDataForm, BasePasswordForm): """Wtform that builds the signup form""" # email_confirmation = TextField( # _('Email confirmation'), # [validators.Email(message=_(u'That\'s not a valid email address.')), # ] # ) accept_tos = BooleanField( _('Have you read and accepted our ' '<a href="javascript:auth.toggleSignupTab(\'tos\')">' 'Terms of use</a>?'), [validators.Required(),], default=True, ) receive_email = BooleanField( _('I want to receive updates by email.'), default=True, ) receive_sms = BooleanField( _('I want to receive updates by sms.'), default=False, )
class EditReleaseForm(Form): shippedAtDate = DateField('Shipped date', format='%Y/%m/%d', validators=[ validators.optional(), ]) shippedAtTime = StringField('Shipped time') isSecurityDriven = BooleanField('Is Security Driven ?') description = TextAreaField('Description') isShipped = BooleanField('Is Shipped ?') def validate_isShipped(form, field): if form.isShipped.data: dt = form.shippedAt if (not dt) or (dt > datetime.now()): raise ValidationError('Invalid Date for Shipped release') @property def shippedAt(self): dateAndTime = None if self.shippedAtDate.data: dt = self.shippedAtDate.data tm = datetime.strptime(self.shippedAtTime.data, '%H:%M:%S').time() dateAndTime = datetime.combine(dt, tm) return dateAndTime
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 RoomClassForm(Form): name = TextField("Name", validators=[Required()]) is_always_authorized = BooleanField("Can Always Boot") printer_configuration_id = SelectField("Printer Configuration") billing_enabled = BooleanField("Billing Enabled", default=True) screensaver_enabled = BooleanField("Idle Screen Enabled", default=True)
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 JobSettingsForm(Form): choices = [] for name in stat.stat_names(): if name == 'glm': for family in stat.glm_families(): x = name + " (" + family + ")" choices.append((x, x)) else: choices.append((name, name)) statistic = SelectField('Statistic', choices=choices) bins = IntegerField('Number of bins', validators=[Required()], default=pade.model.DEFAULT_NUM_BINS) permutations = IntegerField('Maximum number of permutations', validators=[Required()], default=pade.model.DEFAULT_NUM_SAMPLES) sample_from_residuals = BooleanField( 'Sample from residuals', validators=[Required()], default=pade.model.DEFAULT_SAMPLE_FROM_RESIDUALS) sample_with_replacement = BooleanField( 'Use bootstrapping (instead of permutation test)', validators=[Required()], default=pade.model.DEFAULT_SAMPLE_WITH_REPLACEMENT) equalize_means = BooleanField('Equalize means', validators=[Required()], default=pade.model.DEFAULT_EQUALIZE_MEANS) summary_min_conf_level = FloatField( 'Minimum confidence level', validators=[Required()], default=pade.model.DEFAULT_SUMMARY_MIN_CONF) summary_step_size = FloatField( 'Summary step size', validators=[Required()], default=pade.model.DEFAULT_SUMMARY_STEP_SIZE) tuning_params = StringField('Tuning parameters', validators=[Required()], default=' '.join( map(str, pade.model.DEFAULT_TUNING_PARAMS))) submit = SubmitField()
class EntryForm(Form): title = TextField("Title", validators=[required(message="Title required")]) slug = TextField("Slug") tags = TextField("Tags") pub_date = DateTimeField("Published On:", id="date-input", format='%Y-%m-%d') publish = BooleanField('Publish?') delete = BooleanField("Delete?") body = TextAreaField("Body", id='text-editor', validators=[required(message="Body required")]) abstract = TextAreaField("Abstract")
class UserForm(Form): name = TextField("Name", validators=[Length(max=40)]) role = SelectField("Role", coerce=int, validators=[Required()], choices=roles.items()) active = BooleanField('Active', default=True)
class Signup(Form): email = TextField('Email address', [ validators.Required( 'It’s okay, we won’t email you unless you want us to.' ), validators.Email('Um, that doesn’t look like an email address.'), ]) password = PasswordField('Password', [ validators.Required('How else will we know it’s really you?'), validators.EqualTo( 'retype', message= 'If you can’t type it twice now, you’ll never be able to log in with it.' ) ]) retype = PasswordField('Password (again)') consent = BooleanField('Accept the Terms', [ validators.Required('Is there something you don’t agree with?') ]) def validate_email(form, field): if models.User.query.filter_by(email=field.data).count(): raise validators.ValidationError( 'Looks like you’ve already registered. Try logging in instead.' )
class ConfirmForm(Form): terms_accepted = BooleanField( "I accept the terms of service", validators=[ Required( "You must accept the terms of service to publish this listing") ])
class LoginForm(Form): next = HiddenField() remember = BooleanField("Remember me in this computer") login = TextField("Account: ", validators=[ required(message=\ "you must input valid username")]) password = PasswordField("Password: "******"Login")
class CreateLogin(Form): fname = TextField('*First Name', validators=[Required()]) lname = TextField('Last Name', validators=[Optional(strip_whitespace=True)]) mobile = TextField( 'Mobile', validators= # sets optional entry and strips whitespace [ Optional(strip_whitespace=True), v.Length(max=15, message='Mobile exceeds length') ]) zipcode = IntegerField('Zipcode', validators=[Optional(strip_whitespace=True)]) # v.NumberRange(max=9, # message='Zipcode exceeds length')]) email = TextField('*Email', validators=[ Required(), v.Email(), v.EqualTo('confirm_email', message="Emails must match") ]) confirm_email = TextField('*Confirm Email') bio = TextAreaField('Bio', validators=[Length(min=0, max=140)]) password = PasswordField('*Password', validators=[ Required(), v.EqualTo('confirm_password', message='*Passwords must match') ]) confirm_password = PasswordField('Confirm Password') remember_me = BooleanField('Remember Me', default=False) recaptcha = RecaptchaField('*Person Test')
class LoginForm(Form): """ 登录表单 """ login = TextField(_("Email address"), validators=[ required(message=_("You must provide an email")), email(message=_("A valid email address is required")) ]) password = PasswordField( _("Password"), validators=[required(message=_("You must provide an password"))]) recaptcha = TextField( _("Recaptcha"), validators=[]) # required(message=_("You must provide an captcha")) remember = BooleanField(_("Remember me")) next = HiddenField() def validate_recaptcha(self, field): if 'need_verify' not in session or not session['need_verify']: return if 'verify' not in session or session['verify'] != str( field.data).upper(): raise ValidationError, gettext("This captcha is not matching") submit = SubmitField(_("Login"))
class LoginForm(RedirectForm): """ Form for Login """ emailaddress = EmailField("Emailadres", validators=[Required()]) password = PasswordField("Wachtwoord", validators=[Required()]) remember_me = BooleanField("Blijf ingelogd", default=False)
class LoginForm(Form): next = HiddenField() remember = BooleanField(_('Remember me')) login = TextField(_('Username or email address'), [required()]) password = PasswordField(_('Password'), [required(), length(min=6, max=16)]) submit = SubmitField(_('Login'))
class TransactionForm(Form): holding_id = SelectField( 'Holding', description='Commodity holding', coerce=int) type_id = SelectField( 'Type', description='Type of transaction', coerce=int) shares = FloatField( 'Shares', description='Number of shares', validators=univals) price = FloatField( 'Share Price', description='Price per share', validators=univals) date = DateField( 'Date', description='Date the event happened', validators=univals) commissionable = BooleanField( 'Commissionable', description='Were commissions paid?') @classmethod def new(self): form = self() helper = help() tables = ['holding', 'commodity'] fields = ['id', 'symbol'] form.holding_id.choices = helper.get_x_choices(tables, fields) form.holding_id.validators = helper.get_validators('holding', 'id') form.type_id.choices = helper.get_choices('trxn_type', 'id', 'name') form.type_id.validators = helper.get_validators('holding', 'id') return form
class OperatorForm(Form): next = HiddenField() id = HiddenField(default=0) username = TextField(u'帐号', [Required(u'请输入帐号')]) password = PasswordField(u'密码') nickname = TextField(u'姓名', [Required(u'请输入姓名')]) op_id = TextField(u'工号') email = TextField(u'邮箱地址',[Email(u'邮箱格式不正确')]) team = SelectField(u"所属组", [AnyOf([str(val) for val in TEAMS.keys()+DEPARTMENTS.keys()])],choices=TEAM_CHOICES) role = QuerySelectField(u'角色',query_factory=lambda :Role.query.all(),get_label='name') is_admin = BooleanField(u'设为系统管理员') assign_user_type = SelectField(u"指派客户类型", [AnyOf([str(val) for val in OPEARTOR_ASSIGN_USER_TYPES.keys()])],choices=[(str(val), label) for val, label in OPEARTOR_ASSIGN_USER_TYPES.iteritems()]) store_id = SelectField(u"仓库", [AnyOf([str(val) for val in STORES2.keys()])],choices=[(str(val), label) for val, label in STORES2.items()]) #SelectField(u"角色", [AnyOf([str(val) for val in USER_ROLE.keys()])],choices=[(str(val), label) for val, label in USER_ROLE.items()]) #SelectField(u"角色", [AnyOf([str(val) for val in USER_ROLE.keys()])], # choices=[(str(val), label) for val, label in USER_ROLE.items()]) #is_admin = BooleanField(u'是否设为管理员') def validate_password(self,field): operator_id = int(self.id.data) if not operator_id: if not field.data or len(field.data)<6: raise ValidationError(u'密码为空或小于6位') else: if field.data and len(field.data)<6: raise ValidationError(u'密码必须不小于6位') def validate_username(self, field): operator_id = int(self.id.data) if not operator_id: if Operator.query.filter_by(username=field.data).first() is not None: raise ValidationError(u'用户名已存在')
class PageForm(Form): """ This class extends the base Form class from the wtforms package, which takes care of validation and other details for us. """ title = TextField('Event title (e.g. Lowell GOTV Rally)', [validators.Required()]) date = TextField('Date (e.g. June 24, 2013)') time = TextField('Time (e.g. 2:30 pm)') address = TextAreaField('Address') description = TextAreaField('Description') entry = TextAreaField('Event info to be submitted to the Google Doc') filename = TextField( 'Short name for this signup page, to be used for the ' 'filename (e.g. lowell-rally)', [validators.Length(min=6, max=35)]) production = BooleanField('I have previewed by submitting once without ' 'checking this box, and am now ready to upload ' 'it as final (if left unchecked, the page will ' 'be uploaded to the staging bucket for preview)') password = PasswordField('Password')
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() user.user_detail = UserDetail() self.populate_obj(user) db.session.add(user) db.session.commit() return user
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 ParticipantRegistration(Form): username = TextField( "Username", validators=[ MatchesRegex( "[^0-9a-zA-Z\-_]", "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.") ]) receive_emails = BooleanField("I want to receive email notifications.", default=True) captcha = RecaptchaField()
class PostForm(Form): title = TextField('Title', [validators.Length(min=4, max=60)]) author = TextField('Author', [validators.Length(min=4, max=25)]) published = BooleanField('Publish') permalink = TextField('Permanent Link', [validators.Length(min=10, max=60)])
class CreateUserForm(Form): # TODO: NAME字段格式检查的中文支持 next_page = HiddenField() email = TextField(u'Email', description=u'Unique', validators=[Required(message=u'Email is required'), Email(message=u'Incorrect email format'), Unique(User, User.email, message=u'The current email is already in use')]) username = TextField(u'Username', description=u'Unique', validators=[Required(message=u'Username is required'), Regexp(u'^[a-zA-Z0-9\_\-\.]{5,20}$', message=u'Incorrect username format'), Unique(User, User.username, message=u'The current name is already in use')]) name = TextField(u'Name', description=u'Unique', validators=[Required(message=u'Name is required'), Regexp(u'^[a-zA-Z0-9\_\-\.\ ]{1,20}$', message=u'Incorrect name format'), Unique(User, User.name, message=u'The current name is already in use')]) weixin = TextField(u'Weixin OpenID', description=u'Unique, Using the command <code>openid</code> get in WeiXin', validators=[Optional(), Unique(User, User.weixin, message=u'The current weixin OpenID is already in use')]) groups = QuerySelectMultipleField(u'Group', description=u'Multiple Choice', query_factory=Group.query.all, get_label='desc', validators=[Required(message=u'Group is required')]) password = TextField(u'Password', description=u'At least five characters', validators=[Required(message=u'Password is required'), Regexp(u'^.{5,20}$', message=u'Password are at least five chars')]) status = BooleanField(u'Status', description=u'Check to enable this user') submit = SubmitField(u'Submit', id='submit')
class LoginForm(Form): openid = TextField('openid', validators=[Required()]) email = TextField('Email', validators=[Required()]) password = PasswordField('Password', validators=[Required()]) remember = BooleanField('Remember Me', default=False) next = HiddenField('next') submit = SubmitField('submit')
class ConfirmationForm(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)")) first_name = TextField(label=_l("First name")) last_name = TextField(label=_l("Last name")) organization = TextField(label=_l("Organization")) url = TextField(label=_l("URL")) url = TextAreaField(label=_l("Biography"))
class LoginForm(Form): next = HiddenField() remember = BooleanField(u"在这台电脑记住我") login = TextField(u"账号:", validators=[ required(message=\ u"你必须提供一个用户名或是 Email")]) password = PasswordField(u"密码:", [required()]) submit = SubmitField(u"登录")
class LoginForm(Form): next = HiddenField() login = TextField(u'Username or email', [Required()]) password = PasswordField( 'Password', [Required(), Length(PASSWORD_LEN_MIN, PASSWORD_LEN_MAX)]) remember = BooleanField('Remember me') submit = SubmitField('Sign in')
class WithdrawForm(Form): really_withdraw = BooleanField( "Yes, I really want to withdraw the job listing", validators=[ Required( u"If you don’t want to withdraw the listing, just close this page" ) ])
class LoginForm(Form): username = TextField('Username or Email', [validators.Length(min=4, max=255)], filters=[strip_filter]) password = PasswordField('Password', [validators.Length(min=1, max=255)], filters=[strip_filter]) remember_me = BooleanField('Remember me', default=False)