def request_reset(): form = TextField('Email', validators=[validators.Required()]) if form.is_submitted(): if form.validate_on_submit(): if User.query.filter(User.name == form.name.data).count() > 0: flash("That name is already in use, please choose a different name.") render_template("register.html", form=form) if User.query.filter(User.email == form.email.data).count() > 0: flash("That email is already in use. Are you already registered?") render_template("register.html", form=form) u = User(email=form.email.data, password=form.password.data, name=form.name.data, user_type=User.TEACHER) db.session.add(u) db.session.commit() flash('Registration successful!') return redirect(url_for("index")) else: flash("There was an error with your submission") return render_template("register.html", form=form) return render_template("register.html", form=form)
class ContactForm(Form): name = TextField("Name", [validators.Required("Please 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 ForgotPasswordForm(Form): email = TextField('Email', validators=[Required(), Email()]) def validate_email(self, field): if not User.query.filter_by(email=field.data).count(): raise ValidationError('No user with given email found')
class LoginForm(Form): user = TextField(u'Usuário', validators=[Required()]) password = PasswordField(u'Senha', validators=[Required()])
class SessionForm(Form): """ Form used to specify a session identifier to be able to go back to this specific session. """ session_id = TextField("Session identifier", validators=[Required()])
class AddForm(RetrospectiveForm): name = TextField(lazy_gettext('Name'), validators=[validators.Required()], default='RLMS name', description=lazy_gettext("Name of the RLMS")) url = TextField( lazy_gettext('URL'), validators=[validators.URL(require_tld=False), validators.Required()], default='http://rlms-address/', description=lazy_gettext('Main URL of the RLMS')) location = TextField( lazy_gettext('Location'), validators=[validators.Required()], default='City, Country', description=lazy_gettext("City and country where the RLMS is hosted")) publicly_available = BooleanField( lazy_gettext('Public'), default=False, description=lazy_gettext( "Do you want to provide access to this laboratory publicly?")) public_identifier = TextField( lazy_gettext('Public identifier'), default='', description=lazy_gettext( "If publicly available, under what identifier?")) default_autoload = BooleanField( lazy_gettext('Autoload'), default=False, description=lazy_gettext("Should these labs be loaded by default?")) def __init__(self, **kwargs): default_name = getattr( self, 'DEFAULT_NAME', getattr(self, 'DEFAULT_PUBLIC_IDENTIFIER', None)) if default_name: kwargs.setdefault('name', default_name) default_location = getattr(self, 'DEFAULT_LOCATION', None) if default_location: kwargs.setdefault('location', default_location) default_url = getattr(self, 'DEFAULT_URL', None) if default_url: kwargs.setdefault('url', default_url) default_publicly_available = getattr(self, 'DEFAULT_PUBLICLY_AVAILABLE', None) if default_publicly_available is not None: kwargs.setdefault('publicly_available', default_publicly_available) default_public_identifier = getattr(self, 'DEFAULT_PUBLIC_IDENTIFIER', '') if default_public_identifier: kwargs.setdefault('public_identifier', default_public_identifier) default_autoload = getattr(self, 'DEFAULT_AUTOLOAD', None) if default_autoload is not None: kwargs.setdefault('default_autoload', default_autoload) super(AddForm, self).__init__(**kwargs)
class Signup_Form(Form): username = TextField('Username', validators = [Required(), Length(min=4, max=12)]) password = PasswordField('Password', validators = [Length(min=6, max=24), EqualTo('confirm', message='Passwords must match')]) confirm = PasswordField('Confirm Password') email = TextField('E-mail', validators = [Email()]) accept_tos = BooleanField('I accept the terms', validators = [Required()])
class ContactForm(Form): email = html5.EmailField(validators=[Required()]) message = TextField(validators=[Required()])
class CategoryForm(Form): name = TextField(u'类别名称', [Required(u'类别名称不可为空')]) def validate_name(self, field): if Knowledge_Category.query.filter_by(name=field.data).first() is not None: raise ValidationError(u'类别已存在')
class KnowledgeForm(Form): title = TextField(u'标题',[Required(u'输入标题')]) #category_id = QuerySelectField(u'类型',query_factory=lambda :Knowledge_Category.query.all(),get_label='name') content = TextAreaField('内容')
class SettingForm(Form): dst_ex_path = TextField('Path', validators=[Required()]) dst_host = TextField('Path', validators=[Required()]) dst_port = TextField('Path', validators=[Required()], default=21) dst_username = TextField('Path', validators=[Required()]) dst_password = PasswordField('Path', validators=[Required()])
class LoginForm(Form): email = TextField("Email", validators=[Required()]) password = PasswordField("Password", validators=[Required()])
class LoginForm(RedirectForm): username = TextField('Username', [validators.Required()]) password = PasswordField('Password', [validators.Required()])
class SendToMessageForm(Form): recv = TextField(u"收件人", validators=[Required(), Length(max=50)]) title = TextField(u"标题", validators=[Required(), Length(max=50)]) content = TextAreaField(u"内容", validators=[Required(), Length(max=500)])
class LoginForm(Form): username = TextField("username", [Required()]) password = PasswordField("password", [Required()])
class MarkNotisForm(Form): user_id = TextField(u'', validators=[Required()])
class NewsForm(Form): title = TextField(u'标题', [Required(u'标题不可为空')]) content = TextAreaField('内容')
class Upload_Form(Form): name = TextField('Name', validators = [Required(), Length(min=1, max=12)]) img_file = FileField("Image", validators = [file_required()])
class LoginForm(Form): next = HiddenField() username = TextField(u'帐号', [Required(u'帐号为空')]) password = PasswordField('密码', [Required(u'密码为空')])
class RegistrationPermissionForm(RetrospectiveForm): identifier = TextField(lazy_gettext("Identifier"), validators=[Required()])
class PrinterConfigurationForm(Form): name = TextField("Name", validators=[Required()]) configuration = TextField("Configuration Name", validators=[Required()]) description = TextAreaField("Description", validators=[Required()])
class CPUMemForm(Form): cpu = TextField(u'CPU', validators=[Regexp('^[0-9]+$', message=u'CPU核数必须为数字')]) mem = TextField(u'MEM', validators=[Regexp('^[0-9]+$', message=u'内存大小必须为数字')])
class PostForm(Form): post = TextField('post', validators=[Required()])
class ExampleForm(Form): title = TextField(u'Título', validators=[Required()]) content = TextAreaField(u'Conteúdo') date = DateTimeField(u'Data', format='%d/%m/%Y %H:%M')
class SearchForm(Form): search = TextField('search', validators=[Required()])
class PadForm(Form): name = TextField('Name', validators=[Required()])
class LoginForm(Form): openid = TextField('openid', validators=[Required()]) remember_me = BooleanField('remember_me', default=False)
class SigninForm(Form): email = TextField('Email', validators=[Required(), Email()]) password = PasswordField('Password', validators=[Required()])
class LoginForm(Form): username = TextField(u'User Name', validators=[Required()]) password = PasswordField(u'Password', validators=[Required()])
class TopicForm(Form): title = TextField(u'Title', validators=[Required()]) contents = TextAreaField(u'Contents')
class GenericPermissionForm(RetrospectiveForm): identifier = TextField("Identifier", validators = [ Required() ])