Update deprecated code: FlaskForm.
This commit is contained in:
parent
0037c52255
commit
b57df6df6c
|
@ -1,4 +1,4 @@
|
|||
from flask_wtf import Form
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms.fields import StringField, PasswordField, BooleanField, HiddenField, TextAreaField, FileField, IntegerField
|
||||
from wtforms.validators import InputRequired, Email, Length, ValidationError, Regexp, NoneOf, Optional
|
||||
from .model import User, LoginError, re_username, reserved_name, user_exists
|
||||
|
@ -6,7 +6,7 @@ from .model import User, LoginError, re_username, reserved_name, user_exists
|
|||
PASSWORD_LEN = 64
|
||||
EMAIL_LEN = 64
|
||||
|
||||
class SignupForm(Form):
|
||||
class SignupForm(FlaskForm):
|
||||
username = StringField('username',
|
||||
[InputRequired(),
|
||||
Regexp(re_username),
|
||||
|
@ -28,7 +28,7 @@ class SignupForm(Form):
|
|||
if user_exists(User.email, field.data):
|
||||
raise ValidationError('In use by another account')
|
||||
|
||||
class LoginForm(Form):
|
||||
class LoginForm(FlaskForm):
|
||||
user_or_email = StringField('username or e-mail address',
|
||||
[InputRequired(), Length(min=3, max=EMAIL_LEN)],
|
||||
[lambda name: name and name.replace(' ', '_')])
|
||||
|
@ -38,7 +38,7 @@ class LoginForm(Form):
|
|||
next = HiddenField('next')
|
||||
|
||||
def validate(self):
|
||||
rv = Form.validate(self)
|
||||
rv = FlaskForm.validate(self)
|
||||
if not rv:
|
||||
return False
|
||||
|
||||
|
@ -50,33 +50,33 @@ class LoginForm(Form):
|
|||
self.user_or_email.errors.append(e.msg)
|
||||
return False
|
||||
|
||||
class ForgotPasswordForm(Form):
|
||||
class ForgotPasswordForm(FlaskForm):
|
||||
user_or_email = StringField('username or e-mail address',
|
||||
[InputRequired(), Length(max=EMAIL_LEN)])
|
||||
|
||||
class PasswordForm(Form):
|
||||
class PasswordForm(FlaskForm):
|
||||
password = PasswordField('new password',
|
||||
[InputRequired(), Length(min=4, max=PASSWORD_LEN)])
|
||||
|
||||
class AccountSettingsForm(Form):
|
||||
class AccountSettingsForm(FlaskForm):
|
||||
full_name = StringField('full name', [Length(max=64)])
|
||||
email = StringField('e-mail address',
|
||||
[InputRequired(), Email(),
|
||||
Length(min=5, max=EMAIL_LEN)])
|
||||
|
||||
class ChangePasswordForm(Form):
|
||||
class ChangePasswordForm(FlaskForm):
|
||||
old_password = PasswordField('current password',
|
||||
[InputRequired(), Length(max=PASSWORD_LEN)])
|
||||
new_password = PasswordField('new password',
|
||||
[InputRequired(), Length(max=PASSWORD_LEN)])
|
||||
|
||||
class SourceDocForm(Form):
|
||||
class SourceDocForm(FlaskForm):
|
||||
text = TextAreaField('text', [InputRequired()])
|
||||
db_price_per_character = IntegerField('price per character', [Optional()])
|
||||
db_document_price = IntegerField('document price', [Optional()])
|
||||
|
||||
class ItemForm(Form):
|
||||
class ItemForm(FlaskForm):
|
||||
text = TextAreaField('text', [InputRequired()])
|
||||
|
||||
class UploadSourceDocForm(Form):
|
||||
class UploadSourceDocForm(FlaskForm):
|
||||
sourcedoc_file = FileField('SourceDoc', [Regexp(r'^[^/\\]+\.txt$')])
|
||||
|
|
Loading…
Reference in a new issue