Ejemplo n.º 1
0
class ModifyWorkQueueTaskForm(Form):
    """Form for modifying a work queue task."""

    task_id = HiddenField()
    action = HiddenField()
    delete = SubmitField('Delete')
    retry = SubmitField('Retry')
Ejemplo n.º 2
0
class ResponseMessageForm(Form):
    message_id = HiddenField()
    offset = HiddenField()
    comment = TextField(_("Comment"),description=_("What do you have to say about this post"))
    yes = SubmitField(_('Yes')) 
    no = SubmitField(_('No')) 

    def add_response(self,user,parent_id):
        self.populate_obj(user)
        comment = self.comment.data
        resp = self.yes.data
        resp = None if resp == "None" else resp
        if resp:
            timeline = TimeLine()
            timeline.add(user.id, parent_id, agreed = True)

        if(comment == '' and resp == None):
    		return False
        parent = Message()
        parent = parent.get_by_id(parent_id)
        response = Message()
        response.root_id = parent_id if parent.root_id is None else parent_id.root_id
        response.user_id = user.id
        response.parent_id = parent_id
        response.text = comment
        response.response = resp
        response.save()
        parent.last_activity = response.last_activity
        parent.save()
        return True
Ejemplo n.º 3
0
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'用户名已存在')
Ejemplo n.º 4
0
class PrintQueueControlsForm(Form):

    id = HiddenField(validators=[Required()])
    stay_id = HiddenField(validators=[Required()])
    hotel_id = HiddenField(validators=[Required()])
    printer_id = SelectField(validators=[Required()])
    print_item = SubmitField("Print")
Ejemplo n.º 5
0
class RegisterForm(Form):
    """
    User registration form
    """
    email = TextField(_("Email address"),
                      validators=[Required(message=_("Email not provided"))],
                      description=_("Example") + ": [email protected]")
    nickname = TextField(
        _("Nickname"),
        validators=[Required(message=_("Nickname not provided"))],
        description=_("Example") + ": johnd")
    password = PasswordField(
        _("Password"),
        description=_(
            "The password phrase may contain punctuation, spaces, etc."))
    password2 = PasswordField(_("Confirm password"), )
    referer = HiddenField()
    action = HiddenField(default='login')
    submit = SubmitField(_("Register"))

    def validate_nickname(self, field):
        if nickname_valid_p(field.data) != 1:
            raise validators.ValidationError(
                _("Desired nickname %s is invalid.") % field.data)

        # is nickname already taken?
        try:
            User.query.filter(User.nickname == field.data).one()
            raise validators.ValidationError(
                _("Desired nickname %s already exists in the database.") %
                field.data)
        except SQLAlchemyError:
            pass

    def validate_email(self, field):
        field.data = field.data.lower()
        if email_valid_p(field.data.lower()) != 1:
            raise validators.ValidationError(
                _("Supplied email address %s is invalid.") % field.data)

        # is email already taken?
        try:
            User.query.filter(User.email == field.data).one()
            raise validators.ValidationError(
                _("Supplied email address %s already exists in the database.")
                % field.data)
        except SQLAlchemyError:
            pass

    def validate_password(self, field):
        CFG_ACCOUNT_MIN_PASSWORD_LENGTH = 6
        if len(field.data) < CFG_ACCOUNT_MIN_PASSWORD_LENGTH:
            raise validators.ValidationError(
                _("Password must be at least %d characters long." %
                  (CFG_ACCOUNT_MIN_PASSWORD_LENGTH, )))

    def validate_password2(self, field):
        if field.data != self.password.data:
            raise validators.ValidationError(_("Both passwords must match."))
Ejemplo n.º 6
0
class HiddenFieldsForm(Form):
    SECRET_KEY = "a poorly kept secret."
    name = HiddenField()
    url = HiddenField()
    method = HiddenField()
    secret = HiddenField()
    submit = SubmitField("Submit")

    def __init__(self, *args, **kwargs):
        super(HiddenFieldsForm, self).__init__(*args, **kwargs)
        self.method.name = '_method'
Ejemplo n.º 7
0
class ContentCreate_Form(Form):
    next = HiddenField()
    tags_csv = HiddenField()
    title = TextField(
        "Title",
        validators=[validators.required(),
                    validators.Length(max=128)])
    teaser = TextAreaField(
        "Teaser",
        validators=[validators.required(),
                    validators.Length(max=200)])
    content = TextAreaField("Body", validators=[validators.Required()])
    #recaptcha = RecaptchaField()
    submit = SubmitField("Submit")
Ejemplo n.º 8
0
class LoginForm(Form):
    nickname = TextField(_("Nickname"),
                         validators=[
                             Required(message=_("Nickname not provided")),
                             validate_nickname_or_email
                         ])
    password = PasswordField(_("Password"))
    remember = BooleanField(_("Remember Me"))
    referer = HiddenField()
    login_method = HiddenField()
    submit = SubmitField(_("Sign in"))

    def validate_login_method(self, field):
        field.data = wash_login_method(field.data)
Ejemplo n.º 9
0
class ResetPasswordForm(Form):
    activation_key = HiddenField()
    password = PasswordField(u"新密码", validators=[required(message=u"新密码是必须的")])
    password_again = PasswordField(u"密码 <small>(再一次)</small>", validators=[
                                   equal_to("password", message=\
                                            u"密码不匹配")])
    submit = SubmitField(u"保存")
Ejemplo n.º 10
0
class CreateFabfileExecuteForm(Form):

    vars_desc = u'''<p>用 <code>|</code> 作为key(IP地址)和value的分隔符, 用 <code>,</code> 作为value(多个变量赋值)的分隔符, \
    用 <code>=</code> 作为单变量的赋值符。 如:</p>
<code>60.175.193.194|address=61.132.226.195,gateway=61.132.226.254</code>'''

    next_page = HiddenField()

    server_list = TextAreaField(
        u'Server List',
        description=u'Only support ip address. \
    Separated by <code>;</code>、<code>,</code>、<code>空格</code> and <code>换行</code>',
        validators=[Required(message=u'Server list is required')])
    script_template = QuerySelectField(
        u'Fabfile Script',
        description=u'Fabfile Script.',
        query_factory=FabFile.query.all,
        get_label='desc',
        validators=[Required(message=u'Fabfile Script is required')])
    ext_variables = TextAreaField(u'External Variables', description=vars_desc)
    ssh_config = QuerySelectField(
        u'Ssh Config',
        query_factory=SshConfig.query.all,
        get_label='desc',
        validators=[Required(message=u'Ssh config is required')])

    submit = SubmitField(u'Submit', id='submit')
Ejemplo n.º 11
0
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")
Ejemplo n.º 12
0
class ChangePasswordForm(Form):
    activation_key = HiddenField()
    password = PasswordField(u'Password', [Required()])
    password_again = PasswordField(
        u'Password again',
        [EqualTo('password', message="Passwords don't match")])
    submit = SubmitField('Save')
Ejemplo n.º 13
0
class AddAdminForm(Form):
    """Form for adding a build admin."""

    email_address = TextField('Email address',
                              validators=[Length(min=1, max=200)])
    build_id = HiddenField(validators=[NumberRange(min=1)])
    add = SubmitField('Add')
Ejemplo n.º 14
0
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"))
Ejemplo n.º 15
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')
Ejemplo n.º 16
0
class SignupForm(Form):
    '''It is used for sign up, defines sign up form.'''

    next = HiddenField()

    username = TextField(_(u"用户名:"), validators=[
                         required(message=_(u"请输入用户名或者邮箱地址")),
                         is_legal_name])

    password = PasswordField(_(u"密码:"), validators=[
                             required(message=_(u"请输入密码"))])

    password_again = PasswordField(_(u"确认密码:"), validators=[
                                   equal_to(u"password", message=
                                            _(u"密码不一致"))])

    email = TextField(_(u"邮箱地址:"), validators=[
                      required(message=_(u"请输入邮箱地址")),
                      email(message=_(u"请输入有效的邮箱地址"))])

    submit = SubmitField(_(u"注册"))

    def validate_username(self, field):
        user = User.query.filter(User.username.like(field.data)).first()
        if user:
            raise ValidationError(gettext(u"用户名已经存在"))

    def validate_email(self, field):
        user = User.query.filter(User.email.like(field.data)).first()
        if user:
            raise ValidationError(gettext(u"邮箱地址已经存在"))
Ejemplo n.º 17
0
class placeableUpgradeForm(Form):
    name = StringField('Type Name', [validators.Length(min=4, max=20)])
    description = TextAreaField('Describe the Intention of this upgrade',
                                [validators.Length(min=4, max=250)])
    #Upgrde type selectable
    upgrade_type = SelectField(u'Upgrade Type', coerce=unicode)
    del_entity = HiddenField('del_entity')
Ejemplo n.º 18
0
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
Ejemplo n.º 19
0
class ThunderbirdReleaseForm(DesktopReleaseForm):
    product = HiddenField('product')
    commRevision = StringField('Comm Revision:')
    commRelbranch = StringField('Comm Relbranch:', filters=[noneFilter])

    def __init__(self, *args, **kwargs):
        ReleaseForm.__init__(self, prefix='thunderbird', product='thunderbird', *args, **kwargs)

    def validate(self, *args, **kwargs):
        valid = DesktopReleaseForm.validate(self, *args, **kwargs)
        if self.commRelbranch.data:
            self.commRevision.data = self.commRelbranch.data
        else:
            if not self.commRevision.data:
                valid = False
                self.errors['commRevision'] = ['Comm revision is required']

        return valid

    def updateFromRow(self, row):
        self.version.data = row.version
        self.buildNumber.data = row.buildNumber
        self.branch.data = row.branch
        if not row.mozillaRelbranch:
            self.mozillaRevision.data = row.mozillaRevision
        if not row.commRelbranch:
            self.commRevision.data = row.commRevision
        self.partials.data = row.partials
        self.promptWaitTime.data = row.promptWaitTime
        self.dashboardCheck.data = row.dashboardCheck
        self.l10nChangesets.data = row.l10nChangesets
        self.mozillaRelbranch.data = row.mozillaRelbranch
        self.commRelbranch.data = row.commRelbranch
Ejemplo n.º 20
0
class SignupForm(Form):

    next = HiddenField()

    username = TextField(
        u"用户名",
        validators=[required(message=_("Username required")), is_username])

    password = PasswordField(
        u"密码", validators=[required(message=_("Password required"))])

    password_again = PasswordField(u"密码确认", validators=[
                                   equal_to("password", message=\
                                            _("Passwords don't match"))])

    email = TextField(u"邮箱",
                      validators=[
                          required(message=_("Email address required")),
                          email(message=_("A valid email address is required"))
                      ])

    recaptcha = RecaptchaField(_("Copy the words appearing below"))

    submit = SubmitField(u"注册")

    def validate_username(self, field):
        user = User.query.filter(User.username.like(field.data)).first()
        if user:
            raise ValidationError, u"改用户名已存在"

    def validate_email(self, field):
        user = User.query.filter(User.email.like(field.data)).first()
        if user:
            raise ValidationError, gettext("This email is taken")
Ejemplo n.º 21
0
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')
Ejemplo n.º 22
0
class RateEntry(Form):
    entry_id = HiddenField(validators=[Required(), NumberRange(min=1)])
    score_gameplay = IntegerField(
        "Gameplay rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_graphics = IntegerField(
        "Graphics rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_audio = IntegerField(
        "Audio rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_innovation = IntegerField(
        "Innovation rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_story = IntegerField(
        "Story rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_technical = IntegerField(
        "Technical rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_controls = IntegerField(
        "Controls rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    score_overall = IntegerField(
        "Overall rating",
        validators=[Required(), NumberRange(min=1, max=10)],
        default=5)
    note = TextField("Additional notes", validators=[Optional()])
Ejemplo n.º 23
0
class EditCodeForm(Form):
    '''It is used for editing codes, defines edit codes form.'''

    next = HiddenField()
    name = TextField(_(u"名称:"),
                     validators=[required(_(u"请输入名称")), is_legal_name])

    description = TextAreaField(_(u"描述:"))

    related_module = SelectField(_(u"所属模块:"), default=0, coerce=int)

    path = FileField(u"代码文件", validators=[required(message=_(u"请选择文件"))])

    submit = SubmitField(_(u"保存"))

    def __init__(self, code, *args, **kwargs):
        self.code = code
        kwargs['obj'] = self.code
        super(EditCodeForm, self).__init__(*args, **kwargs)

    def validate_name(self, field):
        code = Code.query.filter(
            db.and_(Code.name.like(field.data),
                    db.not_(Code.id == self.code.id))).first()
        if code:
            raise ValidationError(gettext(u"名称已经存在"))
Ejemplo n.º 24
0
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))
Ejemplo n.º 25
0
class ThunderbirdReleaseForm(DesktopReleaseForm):
    product = HiddenField('product')
    commRevision = StringField('Comm Revision:')
    commRelbranch = StringField('Comm Relbranch:', filters=[noneFilter])

    def __init__(self, *args, **kwargs):
        ReleaseForm.__init__(self,
                             prefix='thunderbird',
                             product='thunderbird',
                             *args,
                             **kwargs)

    def validate(self, *args, **kwargs):
        valid = DesktopReleaseForm.validate(self, *args, **kwargs)
        if self.commRelbranch.data:
            self.commRevision.data = self.commRelbranch.data
        else:
            if not self.commRevision.data:
                valid = False
                self.errors['commRevision'] = ['Comm revision is required']

        return valid

    def updateFromRow(self, row):
        DesktopReleaseForm.updateFromRow(self, row)
        self.promptWaitTime.data = row.promptWaitTime
        self.commRelbranch.data = row.commRelbranch
        if not row.commRelbranch:
            self.commRevision.data = row.commRevision
Ejemplo n.º 26
0
class FennecReleaseForm(ReleaseForm):
    product = HiddenField('product')
    l10nChangesets = JSONField(
        'L10n Changesets:',
        validators=[DataRequired('L10n Changesets are required.')])

    def __init__(self, *args, **kwargs):
        ReleaseForm.__init__(self,
                             prefix='fennec',
                             product='fennec',
                             *args,
                             **kwargs)

    def updateFromRow(self, row):
        self.version.data = row.version
        self.buildNumber.data = row.buildNumber
        self.branch.data = row.branch
        # Revision is a disabled field if relbranch is present, so we shouldn't
        # put any data in it.
        if not row.mozillaRelbranch:
            self.mozillaRevision.data = row.mozillaRevision
        self.dashboardCheck.data = row.dashboardCheck
        self.l10nChangesets.data = row.l10nChangesets
        self.mozillaRelbranch.data = row.mozillaRelbranch
        self.mh_changeset.data = row.mh_changeset
Ejemplo n.º 27
0
class AddProductForm(Form):
    user_id = HiddenField('user_id')
    name = TextField('name', validators=[Required()])
    asin = TextField('Amazon Id')
    category_id = TextField('Category')
    default_photo = TextField('Default Photo')
    custom_photo = TextField('Photo')
Ejemplo n.º 28
0
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')
Ejemplo n.º 29
0
class AvatarForm(Form):
    next = HiddenField()
    avatar = FileField(
            label = _("Username"),
            validators = [Required()]
            )
    submit = SubmitField(_('Save'))
Ejemplo n.º 30
0
class SignupForm(Form):
    next = HiddenField()
    name = TextField(_('Username'), [required()])
    password = PasswordField(
        _('Password'),
        [required(), length(min=PASSLEN_MIN, max=PASSLEN_MAX)])
    password_again = PasswordField(_('Password again'), [
        required(),
        length(min=PASSLEN_MIN, max=PASSLEN_MAX),
        equal_to('password')
    ])
    email = TextField(
        _('Email address'),
        [required(),
         email(message=_('A valid email address is required'))])
    invitation_code = TextField(
        _('Invitation Code'),
        [required(message=_('Please fill in the invitation code!'))])
    submit = SubmitField(_('Signup'))

    def validate_name(self, field):
        if g.db.users.find_one({"_id": field.data}) is not None:
            raise ValidationError, _('This username is taken')

    def validate_email(self, field):
        if g.db.users.find_one({"email": field.data}) is not None:
            raise ValidationError, _('This email is taken')

    def validate_invitation_code(self, field):
        if g.db.invitates.find_one({
                "code": field.data,
                "used": 'False'
        }) is None:
            raise ValidationError, _('Invalid code')
Ejemplo n.º 31
0
 def __init__(self, *args, **kwargs):
     validators=[ SpamTrap('Are you a bot or are you cheating?') ]
     kwargs['validators'] = kwargs.get('validators', validators)
     HiddenField.__init__(self, *args, **kwargs)