コード例 #1
0
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"邮箱地址已经存在"))
コード例 #2
0
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,
    )
コード例 #3
0
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
コード例 #4
0
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")
コード例 #5
0
ファイル: room_class.py プロジェクト: kabdessamad1/bluemonk
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)
コード例 #6
0
ファイル: forms.py プロジェクト: pombredanne/owf2013
    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)"))
コード例 #7
0
ファイル: newjob.py プロジェクト: souvikbanerjee91/pade
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()
コード例 #8
0
ファイル: forms.py プロジェクト: feltnerm/flask-blog
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")
コード例 #9
0
ファイル: user.py プロジェクト: kabdessamad1/bluemonk
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)
コード例 #10
0
ファイル: forms.py プロジェクト: bu2/foauth.org
class Signup(Form):
    email = TextField('Email address', [
        validators.Required(
            'It&rsquo;s okay, we won&rsquo;t email you unless you want us to.'
        ),
        validators.Email('Um, that doesn&rsquo;t look like an email address.'),
    ])
    password = PasswordField('Password', [
        validators.Required('How else will we know it&rsquo;s really you?'),
        validators.EqualTo(
            'retype',
            message=
            'If you can&rsquo;t type it twice now, you&rsquo;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&rsquo;t agree with?')
    ])

    def validate_email(form, field):
        if models.User.query.filter_by(email=field.data).count():
            raise validators.ValidationError(
                'Looks like you&rsquo;ve already registered. Try logging in instead.'
            )
コード例 #11
0
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")
        ])
コード例 #12
0
ファイル: account.py プロジェクト: isuker/snippets
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")
コード例 #13
0
ファイル: forms.py プロジェクト: nyghtowl/Sun_Finder
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')
コード例 #14
0
ファイル: account.py プロジェクト: cash2one/cn486
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"))
コード例 #15
0
ファイル: forms.py プロジェクト: MahathirAhamed/flask
class LoginForm(RedirectForm):
  """
  Form for Login
  """
  emailaddress = EmailField("Emailadres", validators=[Required()])
  password = PasswordField("Wachtwoord", validators=[Required()])
  remember_me = BooleanField("Blijf ingelogd", default=False)
コード例 #16
0
ファイル: frontend.py プロジェクト: huntergps/nanoinvoice
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'))
コード例 #17
0
ファイル: forms.py プロジェクト: shintojoseph123/prometheus
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
コード例 #18
0
ファイル: forms.py プロジェクト: LeeJune1992/qxh_ecp
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'用户名已存在')
コード例 #19
0
ファイル: forms.py プロジェクト: isms/boston-python-talk
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')
コード例 #20
0
ファイル: forms.py プロジェクト: thuvh/manekineko
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
コード例 #21
0
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')
コード例 #22
0
ファイル: forms.py プロジェクト: thinker007/flamejam
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()
コード例 #23
0
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)])
コード例 #24
0
ファイル: dashboard.py プロジェクト: lijm1206/Bongos
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')
コード例 #25
0
ファイル: forms.py プロジェクト: jlsalmon/megaproject
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')
コード例 #26
0
ファイル: forms.py プロジェクト: pombredanne/owf2013
    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"))
コード例 #27
0
ファイル: account.py プロジェクト: yxm0513/7topdig
class LoginForm(Form):
    next = HiddenField()
    remember = BooleanField(u"在这台电脑记住我")
    login = TextField(u"账号:", validators=[ required(message=\
                               u"你必须提供一个用户名或是 Email")])
    password = PasswordField(u"密码:", [required()])
    submit = SubmitField(u"登录")
コード例 #28
0
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')
コード例 #29
0
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"
            )
        ])
コード例 #30
0
ファイル: forms.py プロジェクト: plastboks/Flaskmarks
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)