예제 #1
0
 def validate_email(self, field):
     if not utils.validate_email(field.data):
         raise validators.ValidationError(
             _('Invalid email. Enter another email.'))
     user = User.query.filter_by(email=field.data).scalar()
     if user:
         raise validators.ValidationError(
             _('Another participant is already registered with this email '
               'address.'))
 def validate_email(self, field):
     if not utils.validate_email(field.data):
         raise validators.ValidationError(
             _('Invalid email. Enter another email.'))
     user = User.query.filter_by(email=field.data).scalar()
     if user:
         raise validators.ValidationError(
             _('Another participant is already registered with this email '
               'address.'))
def create_superuser(ctx):
    email = click.prompt('Enter email', type=str)
    while not validate_email(email):
        email = click.prompt('Invalid email. Enter another email', type=str)
    password = click.prompt('Enter password', type=str, hide_input=True)
    confirm = click.prompt('Enter password again', type=str, hide_input=True)

    if password == confirm:
        app = ctx.obj['app']
        with app.app_context():
            user = User(email=email, is_superuser=True)
            user.set_password(password)
            db.session.add(user)
            staff = Staff(user=user, full_name='')
            db.session.add(staff)
            db.session.commit()
            click.echo('Superuser has been created')
    else:
        click.echo('Passwords differ')
예제 #4
0
def create_user(ctx):
    email = click.prompt('Enter email', type=str)
    while not validate_email(email):
        email = click.prompt('Invalid email. Enter another email', type=str)
    password = click.prompt('Enter password', type=str, hide_input=True)
    confirm = click.prompt('Enter password again', type=str, hide_input=True)

    if password == confirm:
        app = ctx.obj['app']
        with app.app_context():
            user = User(email=email)
            user.set_password(password)
            db.session.add(user)
            staff = Staff(user=user, full_name='')
            db.session.add(staff)
            db.session.commit()
            click.echo('User has been created')
    else:
        click.echo('Passwords differ')
예제 #5
0
 def __call__(self, form, field):
     emails = field.data.split(self.split_char)
     for email in emails:
         if not validate_email(email.strip()):
             raise validators.ValidationError(self.message)
예제 #6
0
 def __call__(self, form, field):
     emails = field.data.split(self.split_char)
     for email in emails:
         if not validate_email(email.strip()):
             raise validators.ValidationError(self.message)