Beispiel #1
0
class SignupForm(Form):

    next = HiddenField()

    username = TextField(_("Username"), validators=[
                         required(message=_("Username required")), 
                         is_username])

    password = PasswordField(_("Password"), validators=[
                             required(message=_("Password required"))])

    password_again = PasswordField(_("Password again"), validators=[
                                   equal_to("password", message=\
                                            _("Passwords don't match"))])

    email = TextField(_("Email address"), validators=[
                      required(message=_("Email address required")), 
                      email(message=_("A valid email address is required"))])

    recaptcha = RecaptchaField(_("Copy the words appearing below"))

    submit = SubmitField(_("Signup"))

    def validate_username(self, field):
        user = User.query.filter(User.username.like(field.data)).first()
        if user:
            raise ValidationError, gettext("This username is taken")

    def validate_email(self, field):
        user = User.query.filter(User.email.like(field.data)).first()
        if user:
            raise ValidationError, gettext("This email is taken")
Beispiel #2
0
class CommentForm(Form):
    title = TextField("title", [validators.Required()])
    text = TextAreaField("text")
    post_id = HiddenField("post_id")
    comment_id = HiddenField("comment_id")
    delete = BooleanField("delete comment")
    recaptcha = RecaptchaField()
Beispiel #3
0
class SignUpForm(Form):
    ID = TextField(u'身份證字號', validators=[check_ID, NoneOf(ExistingUsersID(), u'此身份證字號已存在,請確認是否已註冊')])
    mobile_phone = TextField(u'行動電話', validators=[Regexp(r'^09\d{8}$', message=u'行動電話號碼格式不正確')])
    email = TextField(u'電子郵件', validators=[Email(u'電子郵件位址格式不正確')])
    password = PasswordField(u'密碼', validators=[Required(u'請設定密碼')])
    chk_password = PasswordField(u'確認密碼', validators=[EqualTo('password', u'兩次輸入的密碼不相符')])
    recaptcha = RecaptchaField(u'圖形驗證', validators=[check_recaptcha_filled, Recaptcha(u'輸入錯誤,請再試一遍')])
Beispiel #4
0
class EntryCommentForm(Form):
    body = TextAreaField("Comment",
                         [Length(min=4, max=1024, message="Required")])
    posted_by_name = TextField("Name",
                               [Length(min=4, max=128, message="Required")])
    posted_by_email = EmailField(
        "E-Mail", [Email("Invalid e-mail address"),
                   Required("Required")])
    return_to = TextField()
    recaptcha = RecaptchaField()
Beispiel #5
0
class RegistrationForm(Form):
    username = TextField(
        'Username', [validators.Required(),
                     validators.Length(min=4, max=25)])
    password = PasswordField('Password', [
        validators.Required(),
        validators.EqualTo('confirm', message='Passwords must match')
    ])
    confirm = PasswordField('Confirm Password', [validators.Required()])
    accept_tos = BooleanField('I accept the TOS', [validators.Required()])
    recaptcha = RecaptchaField()
Beispiel #6
0
class RegistrationForm(Form):
    email = TextField("email",
                      [validators.Email(message="Not a valid email address")])
    username = TextField(
        "username", [validators.Length(min=6),
                     Unique(User, User.username)])
    password = PasswordField("Password", [
        validators.Required(),
        validators.EqualTo("Confirm", message="Passwords must match")
    ])
    confirm = PasswordField("Repeat Password")
    recaptcha = RecaptchaField()
Beispiel #7
0
class DeleteAccountForm(Form):
    
    recaptcha = RecaptchaField(_("Copy the words appearing below"))

    submit = SubmitField(_("Delete"))
Beispiel #8
0
class CommentForm(Form):
    
    comment = TextAreaField("Comment", validators=[Required()])
    recaptcha = RecaptchaField()