mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 14:00:00 +00:00
- replaced deprecated fields by their newer counterparts.
This commit is contained in:
parent
ea77b98a35
commit
6765929c7d
|
@ -6,8 +6,8 @@ import os
|
||||||
import re
|
import re
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from flask_wtf.file import FileField, FileRequired
|
from flask_wtf.file import FileField, FileRequired
|
||||||
from wtforms import TextField, PasswordField, BooleanField, TextAreaField, SelectField
|
from wtforms import StringField, PasswordField, BooleanField, TextAreaField, SelectField
|
||||||
from wtforms.validators import Required, Optional, Email, Length, EqualTo, ValidationError, Regexp
|
from wtforms.validators import DataRequired, Optional, Email, Length, EqualTo, ValidationError, Regexp
|
||||||
|
|
||||||
# For DisabledSelectField
|
# For DisabledSelectField
|
||||||
from wtforms.widgets import Select as SelectWidget
|
from wtforms.widgets import Select as SelectWidget
|
||||||
|
@ -39,27 +39,27 @@ _username_validator = Regexp(
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(FlaskForm):
|
class LoginForm(FlaskForm):
|
||||||
username = TextField('Username or email address', [Required(), _username_validator])
|
username = StringField('Username or email address', [DataRequired(), _username_validator])
|
||||||
password = PasswordField('Password', [Required()])
|
password = PasswordField('Password', [DataRequired()])
|
||||||
|
|
||||||
|
|
||||||
class RegisterForm(FlaskForm):
|
class RegisterForm(FlaskForm):
|
||||||
username = TextField('Username', [
|
username = StringField('Username', [
|
||||||
Required(),
|
DataRequired(),
|
||||||
Length(min=3, max=32),
|
Length(min=3, max=32),
|
||||||
_username_validator,
|
_username_validator,
|
||||||
Unique(User, User.username, 'Username not availiable')
|
Unique(User, User.username, 'Username not availiable')
|
||||||
])
|
])
|
||||||
|
|
||||||
email = TextField('Email address', [
|
email = StringField('Email address', [
|
||||||
Email(),
|
Email(),
|
||||||
Required(),
|
DataRequired(),
|
||||||
Length(min=5, max=128),
|
Length(min=5, max=128),
|
||||||
Unique(User, User.email, 'Email already in use by another account')
|
Unique(User, User.email, 'Email already in use by another account')
|
||||||
])
|
])
|
||||||
|
|
||||||
password = PasswordField('Password', [
|
password = PasswordField('Password', [
|
||||||
Required(),
|
DataRequired(),
|
||||||
EqualTo('password_confirm', message='Passwords must match'),
|
EqualTo('password_confirm', message='Passwords must match'),
|
||||||
Length(min=6, max=1024,
|
Length(min=6, max=1024,
|
||||||
message='Password must be at least %(min)d characters long.')
|
message='Password must be at least %(min)d characters long.')
|
||||||
|
@ -72,14 +72,14 @@ class RegisterForm(FlaskForm):
|
||||||
|
|
||||||
|
|
||||||
class ProfileForm(FlaskForm):
|
class ProfileForm(FlaskForm):
|
||||||
email = TextField('New Email Address', [
|
email = StringField('New Email Address', [
|
||||||
Email(),
|
Email(),
|
||||||
Optional(),
|
Optional(),
|
||||||
Length(min=5, max=128),
|
Length(min=5, max=128),
|
||||||
Unique(User, User.email, 'This email address has been taken')
|
Unique(User, User.email, 'This email address has been taken')
|
||||||
])
|
])
|
||||||
|
|
||||||
current_password = PasswordField('Current Password', [Required()])
|
current_password = PasswordField('Current Password', [DataRequired()])
|
||||||
|
|
||||||
new_password = PasswordField('New Password', [
|
new_password = PasswordField('New Password', [
|
||||||
Optional(),
|
Optional(),
|
||||||
|
@ -124,7 +124,7 @@ class DisabledSelectField(SelectField):
|
||||||
|
|
||||||
|
|
||||||
class EditForm(FlaskForm):
|
class EditForm(FlaskForm):
|
||||||
display_name = TextField('Torrent display name', [
|
display_name = StringField('Torrent display name', [
|
||||||
Length(min=3, max=255,
|
Length(min=3, max=255,
|
||||||
message='Torrent display name must be at least %(min)d characters long '
|
message='Torrent display name must be at least %(min)d characters long '
|
||||||
'and %(max)d at most.')
|
'and %(max)d at most.')
|
||||||
|
@ -153,7 +153,7 @@ class EditForm(FlaskForm):
|
||||||
is_anonymous = BooleanField('Anonymous')
|
is_anonymous = BooleanField('Anonymous')
|
||||||
is_complete = BooleanField('Complete')
|
is_complete = BooleanField('Complete')
|
||||||
|
|
||||||
information = TextField('Information', [
|
information = StringField('Information', [
|
||||||
Length(max=255, message='Information must be at most %(max)d characters long.')
|
Length(max=255, message='Information must be at most %(max)d characters long.')
|
||||||
])
|
])
|
||||||
description = TextAreaField('Description (markdown supported)', [
|
description = TextAreaField('Description (markdown supported)', [
|
||||||
|
@ -170,7 +170,7 @@ class UploadForm(FlaskForm):
|
||||||
FileRequired()
|
FileRequired()
|
||||||
])
|
])
|
||||||
|
|
||||||
display_name = TextField('Torrent display name (optional)', [
|
display_name = StringField('Torrent display name (optional)', [
|
||||||
Optional(),
|
Optional(),
|
||||||
Length(min=3, max=255,
|
Length(min=3, max=255,
|
||||||
message='Torrent display name must be at least %(min)d characters long and '
|
message='Torrent display name must be at least %(min)d characters long and '
|
||||||
|
@ -200,7 +200,7 @@ class UploadForm(FlaskForm):
|
||||||
is_anonymous = BooleanField('Anonymous')
|
is_anonymous = BooleanField('Anonymous')
|
||||||
is_complete = BooleanField('Complete')
|
is_complete = BooleanField('Complete')
|
||||||
|
|
||||||
information = TextField('Information', [
|
information = StringField('Information', [
|
||||||
Length(max=255, message='Information must be at most %(max)d characters long.')
|
Length(max=255, message='Information must be at most %(max)d characters long.')
|
||||||
])
|
])
|
||||||
description = TextAreaField('Description (markdown supported)', [
|
description = TextAreaField('Description (markdown supported)', [
|
||||||
|
|
Loading…
Reference in a new issue