class LoginForm(Form): def __init__(self, *args, **kwargs): Form.__init__(self, *args, **kwargs) self.user = None login = TextField(u'Login', validators=[ validators.required(), ]) password = PasswordField(u'Password', validators=[ validators.required(), ]) remember = BooleanField(u'Remember me') submit = SubmitField(u'Validate') def validate(self): rv = Form.validate(self) if not rv: return False pseudo = self.login.data password = self.password.data try: user_exists(self, self.login) user = check_password(pseudo, password) if user is None: self.password.errors.append('Wrong password.') return False except ValidationError: self.login.errors.append('Unknow user.') return False self.user = user return True
class StatForm(Form): stat = HiddenField('stat_select', id='stat_select', validators=[Required()]) benchmarks = SelectMultipleField('benchmark_select', id='benchmark_select', validators=[Required()]) runs = SelectMultipleField('run_select', id='run_select', validators=[Required()], coerce=str) normalize = BooleanField('normalize', id='normalize', validators=[Required()]) average = BooleanField('average', id='average', validators=[Required()]) hmean = BooleanField('hmean', id='hmean', validators=[Required()]) submit = SubmitField('Update', id='Update')
class RegistrationForm(Form): username = StringField('Username', [validators.Length(min=4, max=25)]) email = StringField('Email Address', [validators.Length(min=6, max=35)]) password = PasswordField('New Password', [ validators.DataRequired(), validators.EqualTo('confirm', message='Passwords must match') ]) confirm = PasswordField('Repeat Password') accept_tos = BooleanField('I accept the TOS', [validators.Required()])
class LoginForm(Form, EmailFormMixin, PasswordFormMixin): " The default login form. " remember = BooleanField(_("Remember Me"), default=True) next = HiddenField() submit = SubmitField(_("Login")) def __init__(self, *args, **kwargs): super(LoginForm, self).__init__(*args, **kwargs) if request.method == 'GET': self.next.data = request.args.get('next', None)
class UserMemberForm(Form): """ The user member form. """ network_id = ConstantField('Identifier') network_name = ConstantField('Network') is_member = BooleanField('Is member') ipv4_address = IPTextField('IPv4 address', ip_version=4, network_only=False) ipv6_address = IPTextField('IPv6 address', ip_version=6, network_only=False)
class NetworkMemberForm(Form): """ The network member form. """ user_id = ConstantField('Identifier') username = ConstantField('Name') email = ConstantField('Email') is_member = BooleanField('Is member') ipv4_address = IPTextField('IPv4 address', ip_version=4, network_only=False) ipv6_address = IPTextField('IPv6 address', ip_version=6, network_only=False)
class UserForm(Form): """ The user form. """ username = TextField( 'Username', [validators.Required(), validators.Length(min=1, max=80)]) current_password = PasswordField('Current password', [validators.Optional()]) new_password = PasswordField('New password', [validators.Optional()]) new_password_repeat = PasswordField( 'Repeat new password', [validators.EqualTo('new_password', message='Passwords must match.')]) email = EmailField('Email', [validators.Required()]) networks = FieldList(FormField(UserMemberForm)) admin_flag = BooleanField('Has administrative privileges')
class LoginForm(Form, NextFormMixin): """The default login form""" email = TextField(get_form_field_label('email')) password = PasswordField(get_form_field_label('password')) remember = BooleanField(get_form_field_label('remember_me')) submit = SubmitField(get_form_field_label('login')) def __init__(self, *args, **kwargs): super(LoginForm, self).__init__(*args, **kwargs) def validate(self): if not super(LoginForm, self).validate(): return False if self.email.data.strip() == '': self.email.errors.append(get_message('EMAIL_NOT_PROVIDED')[0]) return False if self.password.data.strip() == '': self.password.errors.append( get_message('PASSWORD_NOT_PROVIDED')[0]) return False self.user = _datastore.find_user(email=self.email.data) if self.user is None: self.email.errors.append(get_message('USER_DOES_NOT_EXIST')[0]) return False if not verify_and_update_password(self.password.data, self.user): self.password.errors.append(get_message('INVALID_PASSWORD')[0]) return False if requires_confirmation(self.user): self.email.errors.append(get_message('CONFIRMATION_REQUIRED')[0]) return False if not self.user.is_active(): self.email.errors.append(get_message('DISABLED_ACCOUNT')[0]) return False return True
class LoginForm(Form): login = TextField('login', validators=[Required()]) password = PasswordField('password', validators=[Required()]) remember_me = BooleanField('remember_me', default=False)