本文整理匯總了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
示例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
示例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
示例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())
示例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.")
示例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.')
示例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.')
示例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已被使用')
示例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地址已被使用')
示例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)
)
示例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.')
示例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
示例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.")
示例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
示例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