當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。