Пример #1
0
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)
Пример #2
0
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")
Пример #3
0
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')
Пример #4
0
class LoginForm(Form):
    user = TextField(u'Usuário', validators=[Required()])
    password = PasswordField(u'Senha', validators=[Required()])
Пример #5
0
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()])
Пример #6
0
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)
Пример #7
0
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()])
Пример #8
0
class ContactForm(Form):
    email = html5.EmailField(validators=[Required()])
    message = TextField(validators=[Required()])
Пример #9
0
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'类别已存在')
Пример #10
0
class KnowledgeForm(Form):
    title = TextField(u'标题',[Required(u'输入标题')])
    #category_id = QuerySelectField(u'类型',query_factory=lambda :Knowledge_Category.query.all(),get_label='name')
    content = TextAreaField('内容')
Пример #11
0
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()])
Пример #12
0
class LoginForm(Form):
    email = TextField("Email", validators=[Required()])
    password = PasswordField("Password", validators=[Required()])
Пример #13
0
class LoginForm(RedirectForm):
    username = TextField('Username', [validators.Required()])
    password = PasswordField('Password', [validators.Required()])
Пример #14
0
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)])
Пример #15
0
class LoginForm(Form):
    username = TextField("username", [Required()])
    password = PasswordField("password", [Required()])
Пример #16
0
class MarkNotisForm(Form):
    user_id = TextField(u'', validators=[Required()])
Пример #17
0
class NewsForm(Form):
    title = TextField(u'标题', [Required(u'标题不可为空')])
    content = TextAreaField('内容')
Пример #18
0
class Upload_Form(Form):
    name = TextField('Name', validators = [Required(), Length(min=1, max=12)])
    img_file = FileField("Image", validators = [file_required()])
Пример #19
0
class LoginForm(Form):
    next = HiddenField()
    username = TextField(u'帐号', [Required(u'帐号为空')])
    password = PasswordField('密码', [Required(u'密码为空')])
Пример #20
0
class RegistrationPermissionForm(RetrospectiveForm):
    identifier = TextField(lazy_gettext("Identifier"), validators=[Required()])
Пример #21
0
class PrinterConfigurationForm(Form):
    name = TextField("Name", validators=[Required()])
    configuration = TextField("Configuration Name", validators=[Required()])
    description = TextAreaField("Description", validators=[Required()])
Пример #22
0
class CPUMemForm(Form):
    cpu = TextField(u'CPU',
                    validators=[Regexp('^[0-9]+$', message=u'CPU核数必须为数字')])
    mem = TextField(u'MEM',
                    validators=[Regexp('^[0-9]+$', message=u'内存大小必须为数字')])
Пример #23
0
class PostForm(Form):
    post = TextField('post', validators=[Required()])
Пример #24
0
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')
Пример #25
0
class SearchForm(Form):
    search = TextField('search', validators=[Required()])
Пример #26
0
class PadForm(Form):
    name = TextField('Name', validators=[Required()])
Пример #27
0
class LoginForm(Form):
    openid = TextField('openid', validators=[Required()])
    remember_me = BooleanField('remember_me', default=False)
Пример #28
0
class SigninForm(Form):
    email = TextField('Email', validators=[Required(), Email()])
    password = PasswordField('Password', validators=[Required()])
Пример #29
0
class LoginForm(Form):
    username = TextField(u'User Name', validators=[Required()])
    password = PasswordField(u'Password', validators=[Required()])
Пример #30
0
class TopicForm(Form):
    title = TextField(u'Title', validators=[Required()])
    contents = TextAreaField(u'Contents')
Пример #31
0
class GenericPermissionForm(RetrospectiveForm):
    identifier    = TextField("Identifier", validators = [ Required() ])