当前位置: 首页>>代码示例>>Python>>正文


Python validators.Email方法代码示例

本文整理汇总了Python中wtforms.validators.Email方法的典型用法代码示例。如果您正苦于以下问题:Python validators.Email方法的具体用法?Python validators.Email怎么用?Python validators.Email使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在wtforms.validators的用法示例。


在下文中一共展示了validators.Email方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: validate

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate(self):
        initial_validation = super(RegisterForm, self).validate()
        if not initial_validation:
            return False
        user = User.query.filter_by(username=self.username.data).first()
        if user:
            self.username.errors.append("Username already registered")
            return False
        user = User.query.filter_by(email=self.email.data).first()
        if user:
            self.email.errors.append("Email already registered")
            return False
        found_invite_code = Invite_Code.query.filter_by(code=self.invite_code.data).first()
        if not found_invite_code:
            self.invite_code.errors.append("Invite Code not recognized.")
            return False
        if found_invite_code.used:
            self.invite_code.errors.append("Invite Code has already been used.")
            return False
        return True 
开发者ID:codeforamerica,项目名称:comport,代码行数:22,代码来源:forms.py

示例2: validate

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate(self):
        """
        Validate the form.
        """
        initial_validation = super(AdminForm, self).validate()
        if not initial_validation:
            return False
        user = User.query.filter_by(username=self.username.data).first()
        if user and user.user_id != self.user_id.data:
            self.username.errors.append("Username already registered")
            return False
        user = User.query.filter_by(email=self.email.data).first()
        if user and user.user_id != self.user_id.data:
            self.email.errors.append("Email already registered")
            return False
        return True 
开发者ID:ewels,项目名称:MegaQC,代码行数:18,代码来源:forms.py

示例3: uia_email_mapper

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def uia_email_mapper(identity):
    """ Used to match identity as an email.

    See :py:data:`SECURITY_USER_IDENTITY_ATTRIBUTES`.

    .. versionadded:: 3.4.0
    """

    # Fake up enough to invoke the WTforms email validator.
    class FakeField:
        pass

    email_validator = validators.Email(message="nothing")
    field = FakeField()
    field.data = identity
    try:
        email_validator(None, field)
    except ValidationError:
        return None
    return identity 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:22,代码来源:utils.py

示例4: _validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def _validate_email(value):
    if not value:
        raise ValidationError("Email cannot be empty value")
    try:
        if not value.strip():
            raise ValidationError("Email cannot be empty value")
    except AttributeError:
        raise ValidationError("Email cannot be empty value")

    v = Email()

    class dummy_value(object):
        data = value

        @staticmethod
        def gettext(*args, **kwargs):
            return _(*args, **kwargs)

    dummy_form = None
    v(dummy_form, dummy_value()) 
开发者ID:geopython,项目名称:GeoHealthCheck,代码行数:22,代码来源:models.py

示例5: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, email):
        if email.data != current_user.email:
            user = User.query.filter_by(email=email.data).first()
            if user:
                raise ValidationError("\
                Email already exists. Use a different one.") 
开发者ID:pxsocs,项目名称:thewarden,代码行数:8,代码来源:forms.py

示例6: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, field):
        if field.data != self.user.email and \
                User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:6,代码来源:forms.py

示例7: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:5,代码来源:forms.py

示例8: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, field):
        user = User.objects(email=field.data).first()
        if user is not None:
            raise ValidationError(u'Email已被使用') 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:6,代码来源:signup.py

示例9: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, field):
        if current_user.is_authenticated:
            field.data = current_user.user.email
            return True

        if session['email']:
            if session['email'] != field.data:
                raise ValidationError(u'不能修改第三方登录的email地址')
        user = User.objects(email=field.data).first()
        if user:
            raise ValidationError(u'Email地址已被使用') 
开发者ID:DoubleCiti,项目名称:daimaduan.com,代码行数:13,代码来源:userinfo.py

示例10: send_mail

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def send_mail(subject, recipient, template, **context):
    """Send an email.

    :param subject: Email subject
    :param recipient: Email recipient
    :param template: The name of the email template
    :param context: The context to render the template with
    """

    context.setdefault("security", _security)
    context.update(_security._run_ctx_processor("mail"))

    body = None
    html = None
    ctx = ("security/email", template)
    if config_value("EMAIL_PLAINTEXT"):
        body = _security.render_template("%s/%s.txt" % ctx, **context)
    if config_value("EMAIL_HTML"):
        html = _security.render_template("%s/%s.html" % ctx, **context)

    sender = _security.email_sender
    if isinstance(sender, LocalProxy):
        sender = sender._get_current_object()

    _security._mail_util.send_mail(
        template, subject, recipient, str(sender), body, html, context.get("user", None)
    ) 
开发者ID:Flask-Middleware,项目名称:flask-security,代码行数:29,代码来源:utils.py

示例11: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, field):
        if models.User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
开发者ID:CIRCL,项目名称:cve-portal,代码行数:5,代码来源:form_class.py

示例12: validate

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate(self):
        """Validate the form."""
        initial_validation = super(RegisterForm, self).validate()
        if not initial_validation:
            return False
        user = User.query.filter_by(username=self.username.data).first()
        if user:
            self.username.errors.append('Username already registered')
            return False
        user = User.query.filter_by(email=self.email.data).first()
        if user:
            self.email.errors.append('Email already registered')
            return False
        return True 
开发者ID:hackathons-ftw,项目名称:dribdat,代码行数:16,代码来源:forms.py

示例13: validate_email

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError("Email already registered.") 
开发者ID:rtzll,项目名称:flask-todolist,代码行数:5,代码来源:forms.py

示例14: edit_form

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def edit_form(self, obj=None):
        """
        Overrides the editing form to disable toggling
        email activation status on users with a confirmed email.
        """
        form = super(UserView, self).edit_form(obj)

        # Disable the "Email Activated" field if we're attempting to edit
        # a user with an activated account
        if obj is not None and obj.email_activated:
            del form.email_activated

        return form 
开发者ID:radremedy,项目名称:radremedy,代码行数:15,代码来源:userview.py

示例15: validate

# 需要导入模块: from wtforms import validators [as 别名]
# 或者: from wtforms.validators import Email [as 别名]
def validate(self):
        """Validate the form."""
        initial_validation = super(RegisterForm, self).validate()
        if not initial_validation:
            return False
        user = User.query.filter_by(username=self.username.data).first()
        if user:
            self.username.errors.append("Username already registered")
            return False
        user = User.query.filter_by(email=self.email.data).first()
        if user:
            self.email.errors.append("Email already registered")
            return False
        return True 
开发者ID:hjlarry,项目名称:flask-shop,代码行数:16,代码来源:forms.py


注:本文中的wtforms.validators.Email方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。