class Signup(Form): email = TextField('Email address', [ validators.Required( 'It’s okay, we won’t email you unless you want us to.' ), validators.Email('Um, that doesn’t look like an email address.'), ]) password = PasswordField('Password', [ validators.Required('How else will we know it’s really you?'), validators.EqualTo( 'retype', message= 'If you can’t type it twice now, you’ll never be able to log in with it.' ) ]) retype = PasswordField('Password (again)') consent = BooleanField('Accept the Terms', [ validators.Required('Is there something you don’t agree with?') ]) def validate_email(form, field): if models.User.query.filter_by(email=field.data).count(): raise validators.ValidationError( 'Looks like you’ve already registered. Try logging in instead.' )
class Login(Form): email = TextField( 'Email address', validators=[validators.Email('Please supply an email address.')]) password = PasswordField( 'Password', validators=[validators.Required('Please supply a password.')])
class EditForm(Form): username = TextField( 'Username', validators=[validators.LengthOrEmpty(min=3, max=8)]) first_name = TextField('First Name') last_name = TextField('Last Name') dob = TextField( 'Date of Birth (MM/DD/YYYY)', validators=[ validators.Date( format='%m/%d/%Y', message='Invalid format. Please use mm/dd/yyyy.') ]) email = TextField('E-mail Address', validators=[validators.Email()]) sponsor = SelectField('Sponsor', choices=[(s.username, ''.join( (s.last_name, ', ', s.first_name))) for s in database.get_sponsors(True)]) grad_date = TextField( 'Graduation Date (MM/YYYY)', validators=[ validators.Date(format='%m/%Y', message='Invalid format. Please use mm/yyyy') ]) acct_type = RadioField( choices=[('acad', 'Academic'), ('research', 'Research & Academic')]) comments = TextAreaField('Comments') status = TextField('Status')
class SignupForm(Form): firstname = TextField( "First name", [validators.Required("Please enter your first name.")]) lastname = TextField("Last name", [validators.Required("Please enter your last name.")]) email = TextField("Email", [ validators.Required("Please enter your email address."), validators.Email("Please enter your email address.") ]) password = PasswordField('Password', [validators.Required("Please enter a password.")]) submit = SubmitField("Create account") def __init__(self, *args, **kwargs): Form.__init__(self, *args, **kwargs) def validate(self): if not Form.validate(self): return False user = User.query.filter_by(email=self.email.data.lower()).first() if user: self.email.errors.append("That email is already taken") return False else: return True
class RegistrationForm(Form): name = fields.TextField(validators=[validators.required()]) email = fields.TextField(validators=[validators.Email()]) password = fields.PasswordField(validators=[validators.required()]) conf_password = fields.PasswordField(validators=[validators.required()]) def validate_login(self, field): if db.session.query(User).filter_by(username=self.username.data).count() > 0: raise validators.ValidationError('Duplicate username')
class ProfileForm(Form): next = HiddenField() name = TextField(_('Username')) email = TextField(_('email'), [validators.Email()]) website = TextField(_('URL'), [validators.URL()]) location = TextField(_('Location'), [validators.Length(max=100)]) bio = TextAreaField(_('bio'), [validators.Length(max=200)]) submit = SubmitField(_('Save'))
class RegistrationForm(Form): name = fields.TextField(u'First & Last name', [validators.Length(min=5)], description=u'John Doe') email = fields.TextField(u'Email', [validators.Email()], description=u'*****@*****.**') position = fields.TextField(u'Job Position', [validators.Length(min=5)], description=u'Senior Software Developer') company = fields.TextField(u'Company', [validators.Length(min=2)], description=u'Top 10 leader')
class ContactForm(Form): name = TextField("Name", [validators.Required("Name required")]) email = TextField("Email", [ validators.Required("Email required"), validators.Email("Email must be valid") ]) subject = TextField("Subject", [validators.Required("Subject required")]) message = TextAreaField("Message", [validators.Required("Message required")]) submit = SubmitField("Send")
class SetUser(wtforms.form.Form): email = TextField('Email address', [ validators.Required("It's okay, we won't email you unless you want us to."), validators.Email("Um, that doesn't look like an email address."), ]) password = PasswordField('Password', [ validators.Required("How else will we know it's really you?"), ]) retype = PasswordField('Password (again)', [ validators.EqualTo('password', message="If you can't type it twice now, you'll never be able to log in with it."), ])
class RegisterForm(Form): w = TextField('Username', [validators.Length(min=3, max=25), existscheck]) n = TextField('Email Address', [ validators.Length(min=3, max=35), validators.Email(message='Must be a valid email address') ]) s = PasswordField('Password', [ validators.Required(), validators.EqualTo('c', message='Passwords must match') ]) c = PasswordField('Repeat Password')
class ContactForm(Form): name = TextField("Name", [validators.Required("Plase enter your name.")]) email = TextField("Email", [ validators.Required("Please enter your email address."), validators.Email("Please enter your email address.") ]) subject = TextField("Subject", [validators.Required("Please enter a subject.")]) message = TextAreaField("Message", [validators.Required("Please enter a message.")]) submit = SubmitField("Send")
class ContactForm(Form): plexuser = TextField( "Your Plex.tv username", [validators.Required("Please enter a Plex username.")]) name = TextField("Name (optional)", [validators.Optional("Please enter your name.")]) email = TextField("Email (optional to receive confirmation)", [ validators.Optional("Please enter your email address."), validators.Email("Please enter your email address.") ]) submit = SubmitField("Send")
class SignupForm(Form): username = TextField(u'Username', validators=[Required()]) email = TextField(u'Email', validators=[validators.Email()]) password = PasswordField(u'Password', validators=[Required()]) def validate_username(form, field): if Users.query.filter_by(username=field.data).first(): raise ValidationError('Username exsits.') def validate_email(form, field): if Users.query.filter_by(email=field.data).first(): raise ValidationError('Email exsits.')
class EditUserForm(Form): id = HiddenInteger('id') user = TextField( 'user', validators=[validators.Required(), validators.Length(min=3, max=64)]) email = TextField('email', validators=[validators.Required(), validators.Email()]) roles = MultiCheckboxField('roles', validators=[validators.Required()], coerce=int)
class UserRegisterForm(Form): username = TextField('username', [validators.Length(min=4, max=32)], filters=[strip_filter]) email = TextField('email', [ validators.Length(min=4, max=320), validators.Email(message='Not a valid email address') ], filters=[strip_filter]) password = PasswordField('password', [ validators.Length(min=6, max=64), validators.EqualTo('confirm', message='Passwords must match') ], filters=[strip_filter]) confirm = PasswordField('confirm', filters=[strip_filter])
class SignupForm(Form): username = f.TextField('Username', [ v.Length(min=3, max=128), v.Regexp(r'^[^@:]*$', message="Username shouldn't contain '@' or ':'") ]) email = html5.EmailField('Email address', [ v.Length(min=3, max=128), v.Email(message="This should be a valid email address.") ]) password = f.PasswordField('Password', [ v.Required(), v.Length(min=8, message="It's probably best if your password is longer than 8 characters."), v.EqualTo('confirm', message="Passwords must match.") ]) confirm = f.PasswordField('Confirm password') # Will only work if set up in config (see http://packages.python.org/Flask-WTF/) captcha = f.RecaptchaField('Captcha')
class AddUserForm(Form): user = TextField( 'user', validators=[validators.Required(), validators.Length(min=3, max=64)]) email = TextField('email', validators=[validators.Required(), validators.Email()]) password = PasswordField('password', validators=[ validators.Required(), validators.Length(min=3, max=64), validators.EqualTo( 'confirm', 'Both passwords must be equal.') ]) confirm = PasswordField('confirm') roles = MultiCheckboxField('roles', validators=[validators.Required()], coerce=int)
class RegisterForm(Form): firstname = TextField('First Name', [validators.Required()], description=u'First Name') lastname = TextField('Last Name',[validators.Required()], description=u'Last Name') email = TextField('Email',[validators.Email(message= (u'Invalid email address'))], description=u'Email') password = PasswordField('Password', [validators.Required(), validators.length(min=6, max=25)], description=u'Password') address= TextField('Address',[validators.Required()], description=u'Address') city= TextField('City',[validators.Required()], description=u'City') state = TextField('State', [validators.Required(), validators.length(max=2)], description=u'State') zipcode = TextField('Zipcode', [validators.Required()], description=u'Zipcode') country = TextField('Country',[validators.Required()], description=u'Country') dob = DateField('DOB', [validators.Required(message= (u'Enter birthdate: mm/dd/yyyy'))], format= '%m/%d/%Y', description=u'Date of Birth (mm/dd/yyyy)') gender = RadioField('Gender', [validators.Required()], choices=[('male', 'M'),('female','F')], description=u'Gender')
class SigninForm(Form): email = TextField("Email", [ validators.Required("Please enter your email address."), validators.Email("Please enter your email address.") ]) password = PasswordField('Password', [validators.Required("Please enter a password.")]) submit = SubmitField("Sign In") def __init__(self, *args, **kwargs): Form.__init__(self, *args, **kwargs) def validate(self): if not Form.validate(self): return False user = User.query.filter_by(email=self.email.data).first() if user and user.check_password(self.password.data): return True else: self.email.errors.append("Invalid e-mail or password") return False
class ContactForm(Form): name = f.TextField('Name', []) email = html5.EmailField( 'Email address', [v.Email(message="This should be a valid email address.")]) message = f.TextAreaField('Message')
class RegisterForm(Form): username = TextField('Username', validators=[ validators.Required(), validators.Length(min=3, max=8), validators.UniqueColumn( database.User, database.User.username, message='This username is taken.') ]) password = PasswordField('Password', validators=[ validators.Required(), validators.Length(min=8, max=50), validators.CrackLib() ]) first_name = TextField('First Name', validators=[validators.Required()]) last_name = TextField('Last Name', validators=[validators.Required()]) pw_confirm = PasswordField('Confirm Password', validators=[ validators.Required(), validators.Length(min=8, max=50), validators.EqualTo( 'password', message='Passwords do not match.') ]) dob = TextField('Date of Birth (MM/DD/YYYY)', validators=[ validators.Required(), validators.Date( format='%m/%d/%Y', message='Invalid format. Please use mm/dd/yyyy.') ]) email = TextField( 'E-mail Address', validators=[ validators.Email(), validators.Required(), validators.UniqueColumn( database.User, database.User.email, message='This e-mail is in use by another account.') ]) sponsor = SelectField('Sponsor', choices=[(s.username, ''.join( (s.last_name, ', ', s.first_name))) for s in database.get_sponsors()], validators=[validators.Required()]) grad_date = TextField('Graduation Date (MM/YYYY)', validators=[ validators.Required(), validators.Date( format='%m/%Y', message='Invalid format. Please use mm/yyyy') ]) description = TextAreaField('Description of Usage') acct_type = RadioField(choices=[('acad', 'Academic'), ('research', 'Research & Academic')], validators=[validators.Required()]) captcha = RecaptchaField( public_key='6LdeFcwSAAAAAJF1ccPQ4j5Y0Q0iVULdXpRArpcp', private_key='6LdeFcwSAAAAAFv_xLOVLCPAyUQ_abubmG8oUdOw', secure=True)
class LoginForm(Form): email = TextField('Email', [validators.Email(message= (u'Invalid email address'))]) password = PasswordField('Password', [validators.Required(), validators.length(min=6, max=25)])
class LoginForm(RedirectForm): email = TextField('Email', [validators.Required(), validators.Email()]) password = PasswordField('Password', [validators.Required()])
class BaseDataForm(Form): """Form that holds fields used by more forms bellow""" name = TextField( _('Name'), # [validators.Length(min=5)], ) email = TextField( _('Email'), [validators.Email(message=_(u'That\'s not a valid email address.')), ] ) state = SelectField( _('State'), # [validators.Required()], choices=choices.STATES, default='RS', ) city = SelectField( _('City'), # [validators.Required()], choices=choices.CITIES, default=u'Porto Alegre', ) age_group = SelectField( _('Age group'), choices=choices.AGE, ) gender = SelectField( _('Gender'), choices=choices.GENDER, ) phone = TextField( _('Phone'), ) facebook = TextField( _('Facebook'), ) twitter = TextField( _('Twitter'), ) receive_email = BooleanField( _('I want to receive updates by email.'), default=True, ) receive_sms = BooleanField( _('I want to receive updates by sms.'), default=False, ) # def validate_receive_sms(self, field): # print "VALIDANDO RECEBIMENTO DE SMS com ou sem telefone!!!!", field.data, self.phone.data # """Validate if cel-phone number is present""" # if ( (field.data in ['Y','y'] or field.data == True) and not self.phone.data): # raise ValidationError( # _(u'Cel phone number is required')) # def validate_email_confirmation(self, field): # """Compound validation between email and its confirmation""" # if field.data != self.email.data: # raise ValidationError( # _(u'Email does not match its confirmation')) def validate_phone(self, field): if self.receive_sms: if self.receive_sms.data and not field.data: raise ValidationError( _(u'This field is required.'))