Fixes #899 : DeprecationWarning about Required going away in WTForms 3.0. Replaced Required with InputRequired.

This commit is contained in:
Loïc Le Ninan 2014-06-09 15:14:23 +02:00 committed by Christopher Allan Webber
parent b9d990ac6a
commit 0742e11dff
10 changed files with 38 additions and 38 deletions

View File

@ -40,7 +40,7 @@ class EditForm(wtforms.Form):
"Separate tags by commas.")) "Separate tags by commas."))
slug = wtforms.TextField( slug = wtforms.TextField(
_('Slug'), _('Slug'),
[wtforms.validators.Required(message=_("The slug can't be empty"))], [wtforms.validators.InputRequired(message=_("The slug can't be empty"))],
description=_( description=_(
"The title part of this media's address. " "The title part of this media's address. "
"You usually don't need to change this.")) "You usually don't need to change this."))
@ -87,7 +87,7 @@ class EditAttachmentsForm(wtforms.Form):
class EditCollectionForm(wtforms.Form): class EditCollectionForm(wtforms.Form):
title = wtforms.TextField( title = wtforms.TextField(
_('Title'), _('Title'),
[wtforms.validators.Length(min=0, max=500), wtforms.validators.Required(message=_("The title can't be empty"))]) [wtforms.validators.Length(min=0, max=500), wtforms.validators.InputRequired(message=_("The title can't be empty"))])
description = wtforms.TextAreaField( description = wtforms.TextAreaField(
_('Description of this collection'), _('Description of this collection'),
description=_("""You can use description=_("""You can use
@ -95,7 +95,7 @@ class EditCollectionForm(wtforms.Form):
Markdown</a> for formatting.""")) Markdown</a> for formatting."""))
slug = wtforms.TextField( slug = wtforms.TextField(
_('Slug'), _('Slug'),
[wtforms.validators.Required(message=_("The slug can't be empty"))], [wtforms.validators.InputRequired(message=_("The slug can't be empty"))],
description=_( description=_(
"The title part of this collection's address. " "The title part of this collection's address. "
"You usually don't need to change this.")) "You usually don't need to change this."))
@ -104,12 +104,12 @@ class EditCollectionForm(wtforms.Form):
class ChangePassForm(wtforms.Form): class ChangePassForm(wtforms.Form):
old_password = wtforms.PasswordField( old_password = wtforms.PasswordField(
_('Old password'), _('Old password'),
[wtforms.validators.Required()], [wtforms.validators.InputRequired()],
description=_( description=_(
"Enter your old password to prove you own this account.")) "Enter your old password to prove you own this account."))
new_password = wtforms.PasswordField( new_password = wtforms.PasswordField(
_('New password'), _('New password'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
wtforms.validators.Length(min=6, max=30)], wtforms.validators.Length(min=6, max=30)],
id="password") id="password")
@ -117,11 +117,11 @@ class ChangePassForm(wtforms.Form):
class ChangeEmailForm(wtforms.Form): class ChangeEmailForm(wtforms.Form):
new_email = wtforms.TextField( new_email = wtforms.TextField(
_('New email address'), _('New email address'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])
password = wtforms.PasswordField( password = wtforms.PasswordField(
_('Password'), _('Password'),
[wtforms.validators.Required()], [wtforms.validators.InputRequired()],
description=_( description=_(
"Enter your password to prove you own this account.")) "Enter your password to prove you own this account."))

View File

@ -46,7 +46,7 @@ class CsrfForm(Form):
is included in the POST.""" is included in the POST."""
csrf_token = HiddenField("", csrf_token = HiddenField("",
[validators.Required()]) [validators.InputRequired()])
def render_csrf_form_token(request): def render_csrf_form_token(request):

View File

@ -22,22 +22,22 @@ from mediagoblin.auth.tools import normalize_user_or_email_field
class RegistrationForm(wtforms.Form): class RegistrationForm(wtforms.Form):
username = wtforms.TextField( username = wtforms.TextField(
_('Username'), _('Username'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_email=False)]) normalize_user_or_email_field(allow_email=False)])
password = wtforms.PasswordField( password = wtforms.PasswordField(
_('Password'), _('Password'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
wtforms.validators.Length(min=5, max=1024)]) wtforms.validators.Length(min=5, max=1024)])
email = wtforms.TextField( email = wtforms.TextField(
_('Email address'), _('Email address'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])
class LoginForm(wtforms.Form): class LoginForm(wtforms.Form):
username = wtforms.TextField( username = wtforms.TextField(
_('Username or Email'), _('Username or Email'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field()]) normalize_user_or_email_field()])
password = wtforms.PasswordField( password = wtforms.PasswordField(
_('Password')) _('Password'))
@ -49,28 +49,28 @@ class LoginForm(wtforms.Form):
class ForgotPassForm(wtforms.Form): class ForgotPassForm(wtforms.Form):
username = wtforms.TextField( username = wtforms.TextField(
_('Username or email'), _('Username or email'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field()]) normalize_user_or_email_field()])
class ChangeForgotPassForm(wtforms.Form): class ChangeForgotPassForm(wtforms.Form):
password = wtforms.PasswordField( password = wtforms.PasswordField(
'Password', 'Password',
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
wtforms.validators.Length(min=5, max=1024)]) wtforms.validators.Length(min=5, max=1024)])
token = wtforms.HiddenField( token = wtforms.HiddenField(
'', '',
[wtforms.validators.Required()]) [wtforms.validators.InputRequired()])
class ChangePassForm(wtforms.Form): class ChangePassForm(wtforms.Form):
old_password = wtforms.PasswordField( old_password = wtforms.PasswordField(
_('Old password'), _('Old password'),
[wtforms.validators.Required()], [wtforms.validators.InputRequired()],
description=_( description=_(
"Enter your old password to prove you own this account.")) "Enter your old password to prove you own this account."))
new_password = wtforms.PasswordField( new_password = wtforms.PasswordField(
_('New password'), _('New password'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
wtforms.validators.Length(min=6, max=30)], wtforms.validators.Length(min=6, max=30)],
id="password") id="password")

View File

@ -22,19 +22,19 @@ from mediagoblin.auth.tools import normalize_user_or_email_field
class RegisterForm(wtforms.Form): class RegisterForm(wtforms.Form):
username = wtforms.HiddenField( username = wtforms.HiddenField(
'', '',
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_email=False)]) normalize_user_or_email_field(allow_email=False)])
email = wtforms.TextField( email = wtforms.TextField(
_('Email address'), _('Email address'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])
class LoginForm(wtforms.Form): class LoginForm(wtforms.Form):
username = wtforms.TextField( username = wtforms.TextField(
_('Username'), _('Username'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field()]) normalize_user_or_email_field()])
password = wtforms.PasswordField( password = wtforms.PasswordField(
_('Password'), _('Password'),
[wtforms.validators.Required()]) [wtforms.validators.InputRequired()])

View File

@ -24,21 +24,21 @@ from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
class AuthorizationForm(wtforms.Form): class AuthorizationForm(wtforms.Form):
client_id = wtforms.HiddenField(u'', client_id = wtforms.HiddenField(u'',
validators=[wtforms.validators.Required()]) validators=[wtforms.validators.InputRequired()])
next = wtforms.HiddenField(u'', validators=[wtforms.validators.Required()]) next = wtforms.HiddenField(u'', validators=[wtforms.validators.InputRequired()])
allow = wtforms.SubmitField(_(u'Allow')) allow = wtforms.SubmitField(_(u'Allow'))
deny = wtforms.SubmitField(_(u'Deny')) deny = wtforms.SubmitField(_(u'Deny'))
class ClientRegistrationForm(wtforms.Form): class ClientRegistrationForm(wtforms.Form):
name = wtforms.TextField(_('Name'), [wtforms.validators.Required()], name = wtforms.TextField(_('Name'), [wtforms.validators.InputRequired()],
description=_('The name of the OAuth client')) description=_('The name of the OAuth client'))
description = wtforms.TextAreaField(_('Description'), description = wtforms.TextAreaField(_('Description'),
[wtforms.validators.Length(min=0, max=500)], [wtforms.validators.Length(min=0, max=500)],
description=_('''This will be visible to users allowing your description=_('''This will be visible to users allowing your
application to authenticate as them.''')) application to authenticate as them.'''))
type = wtforms.SelectField(_('Type'), type = wtforms.SelectField(_('Type'),
[wtforms.validators.Required()], [wtforms.validators.InputRequired()],
choices=[ choices=[
('confidential', 'Confidential'), ('confidential', 'Confidential'),
('public', 'Public')], ('public', 'Public')],

View File

@ -22,20 +22,20 @@ from mediagoblin.auth.tools import normalize_user_or_email_field
class RegistrationForm(wtforms.Form): class RegistrationForm(wtforms.Form):
openid = wtforms.HiddenField( openid = wtforms.HiddenField(
'', '',
[wtforms.validators.Required()]) [wtforms.validators.InputRequired()])
username = wtforms.TextField( username = wtforms.TextField(
_('Username'), _('Username'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_email=False)]) normalize_user_or_email_field(allow_email=False)])
email = wtforms.TextField( email = wtforms.TextField(
_('Email address'), _('Email address'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])
class LoginForm(wtforms.Form): class LoginForm(wtforms.Form):
openid = wtforms.TextField( openid = wtforms.TextField(
_('OpenID'), _('OpenID'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
# Can openid's only be urls? # Can openid's only be urls?
wtforms.validators.URL(message='Please enter a valid url.')]) wtforms.validators.URL(message='Please enter a valid url.')])

View File

@ -22,20 +22,20 @@ from mediagoblin.auth.tools import normalize_user_or_email_field
class RegistrationForm(wtforms.Form): class RegistrationForm(wtforms.Form):
username = wtforms.TextField( username = wtforms.TextField(
_('Username'), _('Username'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_email=False)]) normalize_user_or_email_field(allow_email=False)])
email = wtforms.TextField( email = wtforms.TextField(
_('Email address'), _('Email address'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])
persona_email = wtforms.HiddenField( persona_email = wtforms.HiddenField(
'', '',
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])
class EditForm(wtforms.Form): class EditForm(wtforms.Form):
email = wtforms.TextField( email = wtforms.TextField(
_('Email address'), _('Email address'),
[wtforms.validators.Required(), [wtforms.validators.InputRequired(),
normalize_user_or_email_field(allow_user=False)]) normalize_user_or_email_field(allow_user=False)])

View File

@ -34,7 +34,7 @@ _md5_validator = wtforms.validators.Regexp(r"^[0-9a-fA-F]{32}$")
class AddForm(wtforms.Form): class AddForm(wtforms.Form):
original_sum = wtforms.TextField(None, original_sum = wtforms.TextField(None,
[_md5_validator, [_md5_validator,
wtforms.validators.Required()]) wtforms.validators.InputRequired()])
thumbnail_sum = wtforms.TextField(None, thumbnail_sum = wtforms.TextField(None,
[wtforms.validators.Optional(), [wtforms.validators.Optional(),
_md5_validator]) _md5_validator])

View File

@ -59,7 +59,7 @@ def get_submit_start_form(form, **kwargs):
class AddCollectionForm(wtforms.Form): class AddCollectionForm(wtforms.Form):
title = wtforms.TextField( title = wtforms.TextField(
_('Title'), _('Title'),
[wtforms.validators.Length(min=0, max=500), wtforms.validators.Required()]) [wtforms.validators.Length(min=0, max=500), wtforms.validators.InputRequired()])
description = wtforms.TextAreaField( description = wtforms.TextAreaField(
_('Description of this collection'), _('Description of this collection'),
description=_("""You can use description=_("""You can use

View File

@ -21,7 +21,7 @@ from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
class MediaCommentForm(wtforms.Form): class MediaCommentForm(wtforms.Form):
comment_content = wtforms.TextAreaField( comment_content = wtforms.TextAreaField(
_('Comment'), _('Comment'),
[wtforms.validators.Required()], [wtforms.validators.InputRequired()],
description=_(u'You can use ' description=_(u'You can use '
u'<a href="http://daringfireball.net/projects/markdown/basics" target="_blank">' u'<a href="http://daringfireball.net/projects/markdown/basics" target="_blank">'
u'Markdown</a> for formatting.')) u'Markdown</a> for formatting.'))
@ -53,11 +53,11 @@ class MediaCollectForm(wtforms.Form):
class CommentReportForm(wtforms.Form): class CommentReportForm(wtforms.Form):
report_reason = wtforms.TextAreaField( report_reason = wtforms.TextAreaField(
_('Reason for Reporting'), _('Reason for Reporting'),
[wtforms.validators.Required()]) [wtforms.validators.InputRequired()])
reporter_id = wtforms.HiddenField('') reporter_id = wtforms.HiddenField('')
class MediaReportForm(wtforms.Form): class MediaReportForm(wtforms.Form):
report_reason = wtforms.TextAreaField( report_reason = wtforms.TextAreaField(
_('Reason for Reporting'), _('Reason for Reporting'),
[wtforms.validators.Required()]) [wtforms.validators.InputRequired()])
reporter_id = wtforms.HiddenField('') reporter_id = wtforms.HiddenField('')