Ejemplo n.º 1
0
class PostForm(Form):
    title = StringField('Title', [
        validators.length(max=50, message='Titles must not exceed 50 chars.'),
        validators.required(message='Please enter a title.')
    ])
    subject = StringField('Subject', [
        validators.length(max=100,
                          message='Subject must not exceed 100 chars.')
    ])
    content = TextAreaField('Content', [
        validators.length(max=1800,
                          message='Content must not exceed 1,800 chars.'),
        validators.required(message='Please enter some content for the post.')
    ])
    csrf_token = HiddenField()
Ejemplo n.º 2
0
def get_TextField(kwargs):
    """
    Returns a ``TextField``, applying the ``db.StringProperty`` length limit
    of 500 bytes.
    """
    kwargs['validators'].append(validators.length(max=500))
    return f.TextField(**kwargs)
Ejemplo n.º 3
0
def convert_StringProperty(model, prop, kwargs):
    """Returns a form field for a ``db.StringProperty``."""
    if prop.multiline:
        kwargs['validators'].append(validators.length(max=500))
        return f.TextAreaField(**kwargs)
    else:
        return get_TextField(kwargs)
Ejemplo n.º 4
0
class CommentForm(Form):
    comment = TextAreaField('Comment', [
        validators.length(
            max=120, message='Comments must be less than 120 characters.'),
        validators.required(message='Please enter your comment.')
    ])
    key = HiddenField()
    csrf_token = HiddenField()
Ejemplo n.º 5
0
class LoginForm(Form):
    username = StringField('Username',
                           [validators.Length(min=5, max=15, message='Username must be 5-15 chars'),
                            validators.required()])
    password = PasswordField('Password',
                             [validators.length(min=8, max=30, message='Password must be 8-30 chars'),
                              validators.required()])
    csrf_token = HiddenField()
Ejemplo n.º 6
0
class RegisterForm(Form):
    username = StringField('Username', [
        validators.Length(
            min=5, max=15, message='Username must be 5-15 chars.'),
        validators.required()
    ])
    password = PasswordField('Password', [
        validators.length(
            min=8, max=30, message='Password must be 8-30 chars.'),
        validators.required(),
        validators.equal_to('confirm', message='Passwords must match.')
    ])
    confirm = PasswordField('Confirm', [
        validators.length(
            min=8, max=30, message='Password must be 8-30 chars.'),
        validators.required()
    ])
    csrf_token = HiddenField()