Python wtforms.validators.Email() Examples

The following are 30 code examples of wtforms.validators.Email(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module wtforms.validators , or try the search function .
Example #1
Source Project: comport   Author: codeforamerica   File: forms.py    License: BSD 3-Clause "New" or "Revised" License 7 votes vote down vote up
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 
Example #2
Source Project: MegaQC   Author: ewels   File: forms.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 
Example #3
Source Project: MegaQC   Author: ewels   File: forms.py    License: GNU General Public License v3.0 6 votes vote down vote up
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 
Example #4
Source Project: flask-security   Author: Flask-Middleware   File: utils.py    License: MIT License 6 votes vote down vote up
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 
Example #5
Source Project: GeoHealthCheck   Author: geopython   File: models.py    License: MIT License 6 votes vote down vote up
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()) 
Example #6
Source Project: thewarden   Author: pxsocs   File: forms.py    License: MIT License 5 votes vote down vote up
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.") 
Example #7
Source Project: circleci-demo-python-flask   Author: CircleCI-Public   File: forms.py    License: MIT License 5 votes vote down vote up
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.') 
Example #8
Source Project: circleci-demo-python-flask   Author: CircleCI-Public   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #9
Source Project: circleci-demo-python-flask   Author: CircleCI-Public   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #10
Source Project: Flashcards   Author: KevDi   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #11
Source Project: Flashcards   Author: KevDi   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already address.') 
Example #12
Source Project: daimaduan.com   Author: DoubleCiti   File: signup.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def validate_email(self, field):
        user = User.objects(email=field.data).first()
        if user is not None:
            raise ValidationError(u'Email已被使用') 
Example #13
Source Project: daimaduan.com   Author: DoubleCiti   File: userinfo.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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地址已被使用') 
Example #14
Source Project: flask-security   Author: Flask-Middleware   File: utils.py    License: MIT License 5 votes vote down vote up
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)
    ) 
Example #15
Source Project: cve-portal   Author: CIRCL   File: form_class.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def validate_email(self, field):
        if models.User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #16
Source Project: cve-portal   Author: CIRCL   File: form_class.py    License: GNU Affero General Public License v3.0 5 votes vote down vote up
def validate_email(self, field):
        if models.User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #17
Source Project: dribdat   Author: hackathons-ftw   File: forms.py    License: MIT License 5 votes vote down vote up
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 
Example #18
Source Project: flask-todolist   Author: rtzll   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError("Email already registered.") 
Example #19
Source Project: radremedy   Author: radremedy   File: userview.py    License: Mozilla Public License 2.0 5 votes vote down vote up
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 
Example #20
Source Project: flask-shop   Author: hjlarry   File: forms.py    License: BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
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 
Example #21
Source Project: BhagavadGita   Author: gita   File: forms.py    License: GNU General Public License v3.0 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #22
Source Project: BhagavadGita   Author: gita   File: forms.py    License: GNU General Public License v3.0 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #23
Source Project: BhagavadGita   Author: gita   File: forms.py    License: GNU General Public License v3.0 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError(
                'Email already registered. (Did you mean to log in instead?)') 
Example #24
Source Project: BhagavadGita   Author: gita   File: forms.py    License: GNU General Public License v3.0 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #25
Source Project: gitmark   Author: GitMarkTeam   File: forms.py    License: GNU General Public License v2.0 5 votes vote down vote up
def validate_email(self, field):
        if models.User.objects.filter(email=field.data).count() > 0:
            raise ValidationError('Email already in registered') 
Example #26
Source Project: gitmark   Author: GitMarkTeam   File: forms.py    License: GNU General Public License v2.0 5 votes vote down vote up
def validate_email(self, field):
        users = models.User.objects.filter(email=field.data)
        if users.count() > 0 and users[0].id != current_user.id:
            raise ValidationError('Email already in registered') 
Example #27
Source Project: braindump   Author: levlaz   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #28
Source Project: penn-club-ratings   Author: abhisuri97   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #29
Source Project: penn-club-ratings   Author: abhisuri97   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered.') 
Example #30
Source Project: penn-club-ratings   Author: abhisuri97   File: forms.py    License: MIT License 5 votes vote down vote up
def validate_email(self, field):
        if User.query.filter_by(email=field.data).first():
            raise ValidationError('Email already registered. (Did you mean to '
                                  '<a href="{}">log in</a> instead?)'.format(
                                      url_for('account.login')))