From e85efe5e6a4da96452ec030fdefd8d0883b5097e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Le=20Ninan?= <loic.leninan@gmail.com>
Date: Mon, 9 Jun 2014 15:14:23 +0200
Subject: [PATCH] Fixes #899 : DeprecationWarning about Required going away in
WTForms 3.0. Replaced Required with InputRequired.
---
mediagoblin/edit/forms.py | 14 +++++++-------
mediagoblin/meddleware/csrf.py | 2 +-
mediagoblin/plugins/basic_auth/forms.py | 18 +++++++++---------
mediagoblin/plugins/ldap/forms.py | 8 ++++----
mediagoblin/plugins/oauth/forms.py | 8 ++++----
mediagoblin/plugins/openid/forms.py | 8 ++++----
mediagoblin/plugins/persona/forms.py | 8 ++++----
mediagoblin/plugins/piwigo/forms.py | 2 +-
mediagoblin/submit/forms.py | 2 +-
mediagoblin/user_pages/forms.py | 6 +++---
10 files changed, 38 insertions(+), 38 deletions(-)
diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py
index 7c390a3..c0bece8 100644
|
a
|
b
|
class EditForm(wtforms.Form):
|
| 40 | 40 | "Separate tags by commas.")) |
| 41 | 41 | slug = wtforms.TextField( |
| 42 | 42 | _('Slug'), |
| 43 | | [wtforms.validators.Required(message=_("The slug can't be empty"))], |
| | 43 | [wtforms.validators.InputRequired(message=_("The slug can't be empty"))], |
| 44 | 44 | description=_( |
| 45 | 45 | "The title part of this media's address. " |
| 46 | 46 | "You usually don't need to change this.")) |
| … |
… |
class EditAttachmentsForm(wtforms.Form):
|
| 87 | 87 | class EditCollectionForm(wtforms.Form): |
| 88 | 88 | title = wtforms.TextField( |
| 89 | 89 | _('Title'), |
| 90 | | [wtforms.validators.Length(min=0, max=500), wtforms.validators.Required(message=_("The title can't be empty"))]) |
| | 90 | [wtforms.validators.Length(min=0, max=500), wtforms.validators.InputRequired(message=_("The title can't be empty"))]) |
| 91 | 91 | description = wtforms.TextAreaField( |
| 92 | 92 | _('Description of this collection'), |
| 93 | 93 | description=_("""You can use |
| … |
… |
class EditCollectionForm(wtforms.Form):
|
| 95 | 95 | Markdown</a> for formatting.""")) |
| 96 | 96 | slug = wtforms.TextField( |
| 97 | 97 | _('Slug'), |
| 98 | | [wtforms.validators.Required(message=_("The slug can't be empty"))], |
| | 98 | [wtforms.validators.InputRequired(message=_("The slug can't be empty"))], |
| 99 | 99 | description=_( |
| 100 | 100 | "The title part of this collection's address. " |
| 101 | 101 | "You usually don't need to change this.")) |
| … |
… |
class EditCollectionForm(wtforms.Form):
|
| 104 | 104 | class ChangePassForm(wtforms.Form): |
| 105 | 105 | old_password = wtforms.PasswordField( |
| 106 | 106 | _('Old password'), |
| 107 | | [wtforms.validators.Required()], |
| | 107 | [wtforms.validators.InputRequired()], |
| 108 | 108 | description=_( |
| 109 | 109 | "Enter your old password to prove you own this account.")) |
| 110 | 110 | new_password = wtforms.PasswordField( |
| 111 | 111 | _('New password'), |
| 112 | | [wtforms.validators.Required(), |
| | 112 | [wtforms.validators.InputRequired(), |
| 113 | 113 | wtforms.validators.Length(min=6, max=30)], |
| 114 | 114 | id="password") |
| 115 | 115 | |
| … |
… |
class ChangePassForm(wtforms.Form):
|
| 117 | 117 | class ChangeEmailForm(wtforms.Form): |
| 118 | 118 | new_email = wtforms.TextField( |
| 119 | 119 | _('New email address'), |
| 120 | | [wtforms.validators.Required(), |
| | 120 | [wtforms.validators.InputRequired(), |
| 121 | 121 | normalize_user_or_email_field(allow_user=False)]) |
| 122 | 122 | password = wtforms.PasswordField( |
| 123 | 123 | _('Password'), |
| 124 | | [wtforms.validators.Required()], |
| | 124 | [wtforms.validators.InputRequired()], |
| 125 | 125 | description=_( |
| 126 | 126 | "Enter your password to prove you own this account.")) |
| 127 | 127 | |
diff --git a/mediagoblin/meddleware/csrf.py b/mediagoblin/meddleware/csrf.py
index 44d42d7..6cad6fa 100644
|
a
|
b
|
class CsrfForm(Form):
|
| 46 | 46 | is included in the POST.""" |
| 47 | 47 | |
| 48 | 48 | csrf_token = HiddenField("", |
| 49 | | [validators.Required()]) |
| | 49 | [validators.InputRequired()]) |
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | def render_csrf_form_token(request): |
diff --git a/mediagoblin/plugins/basic_auth/forms.py b/mediagoblin/plugins/basic_auth/forms.py
index c10496f..42b84bf 100644
|
a
|
b
|
from mediagoblin.auth.tools import normalize_user_or_email_field
|
| 22 | 22 | class RegistrationForm(wtforms.Form): |
| 23 | 23 | username = wtforms.TextField( |
| 24 | 24 | _('Username'), |
| 25 | | [wtforms.validators.Required(), |
| | 25 | [wtforms.validators.InputRequired(), |
| 26 | 26 | normalize_user_or_email_field(allow_email=False)]) |
| 27 | 27 | password = wtforms.PasswordField( |
| 28 | 28 | _('Password'), |
| 29 | | [wtforms.validators.Required(), |
| | 29 | [wtforms.validators.InputRequired(), |
| 30 | 30 | wtforms.validators.Length(min=5, max=1024)]) |
| 31 | 31 | email = wtforms.TextField( |
| 32 | 32 | _('Email address'), |
| 33 | | [wtforms.validators.Required(), |
| | 33 | [wtforms.validators.InputRequired(), |
| 34 | 34 | normalize_user_or_email_field(allow_user=False)]) |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | class LoginForm(wtforms.Form): |
| 38 | 38 | username = wtforms.TextField( |
| 39 | 39 | _('Username or Email'), |
| 40 | | [wtforms.validators.Required(), |
| | 40 | [wtforms.validators.InputRequired(), |
| 41 | 41 | normalize_user_or_email_field()]) |
| 42 | 42 | password = wtforms.PasswordField( |
| 43 | 43 | _('Password')) |
| … |
… |
class LoginForm(wtforms.Form):
|
| 49 | 49 | class ForgotPassForm(wtforms.Form): |
| 50 | 50 | username = wtforms.TextField( |
| 51 | 51 | _('Username or email'), |
| 52 | | [wtforms.validators.Required(), |
| | 52 | [wtforms.validators.InputRequired(), |
| 53 | 53 | normalize_user_or_email_field()]) |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | class ChangeForgotPassForm(wtforms.Form): |
| 57 | 57 | password = wtforms.PasswordField( |
| 58 | 58 | 'Password', |
| 59 | | [wtforms.validators.Required(), |
| | 59 | [wtforms.validators.InputRequired(), |
| 60 | 60 | wtforms.validators.Length(min=5, max=1024)]) |
| 61 | 61 | token = wtforms.HiddenField( |
| 62 | 62 | '', |
| 63 | | [wtforms.validators.Required()]) |
| | 63 | [wtforms.validators.InputRequired()]) |
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | class ChangePassForm(wtforms.Form): |
| 67 | 67 | old_password = wtforms.PasswordField( |
| 68 | 68 | _('Old password'), |
| 69 | | [wtforms.validators.Required()], |
| | 69 | [wtforms.validators.InputRequired()], |
| 70 | 70 | description=_( |
| 71 | 71 | "Enter your old password to prove you own this account.")) |
| 72 | 72 | new_password = wtforms.PasswordField( |
| 73 | 73 | _('New password'), |
| 74 | | [wtforms.validators.Required(), |
| | 74 | [wtforms.validators.InputRequired(), |
| 75 | 75 | wtforms.validators.Length(min=6, max=30)], |
| 76 | 76 | id="password") |
diff --git a/mediagoblin/plugins/ldap/forms.py b/mediagoblin/plugins/ldap/forms.py
index 7ec1479..1f1439a 100644
|
a
|
b
|
from mediagoblin.auth.tools import normalize_user_or_email_field
|
| 22 | 22 | class RegisterForm(wtforms.Form): |
| 23 | 23 | username = wtforms.HiddenField( |
| 24 | 24 | '', |
| 25 | | [wtforms.validators.Required(), |
| | 25 | [wtforms.validators.InputRequired(), |
| 26 | 26 | normalize_user_or_email_field(allow_email=False)]) |
| 27 | 27 | email = wtforms.TextField( |
| 28 | 28 | _('Email address'), |
| 29 | | [wtforms.validators.Required(), |
| | 29 | [wtforms.validators.InputRequired(), |
| 30 | 30 | normalize_user_or_email_field(allow_user=False)]) |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | class LoginForm(wtforms.Form): |
| 34 | 34 | username = wtforms.TextField( |
| 35 | 35 | _('Username'), |
| 36 | | [wtforms.validators.Required(), |
| | 36 | [wtforms.validators.InputRequired(), |
| 37 | 37 | normalize_user_or_email_field()]) |
| 38 | 38 | password = wtforms.PasswordField( |
| 39 | 39 | _('Password'), |
| 40 | | [wtforms.validators.Required()]) |
| | 40 | [wtforms.validators.InputRequired()]) |
diff --git a/mediagoblin/plugins/oauth/forms.py b/mediagoblin/plugins/oauth/forms.py
index 5edd992..ddf4d39 100644
|
a
|
b
|
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
|
| 24 | 24 | |
| 25 | 25 | class AuthorizationForm(wtforms.Form): |
| 26 | 26 | client_id = wtforms.HiddenField(u'', |
| 27 | | validators=[wtforms.validators.Required()]) |
| 28 | | next = wtforms.HiddenField(u'', validators=[wtforms.validators.Required()]) |
| | 27 | validators=[wtforms.validators.InputRequired()]) |
| | 28 | next = wtforms.HiddenField(u'', validators=[wtforms.validators.InputRequired()]) |
| 29 | 29 | allow = wtforms.SubmitField(_(u'Allow')) |
| 30 | 30 | deny = wtforms.SubmitField(_(u'Deny')) |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | class ClientRegistrationForm(wtforms.Form): |
| 34 | | name = wtforms.TextField(_('Name'), [wtforms.validators.Required()], |
| | 34 | name = wtforms.TextField(_('Name'), [wtforms.validators.InputRequired()], |
| 35 | 35 | description=_('The name of the OAuth client')) |
| 36 | 36 | description = wtforms.TextAreaField(_('Description'), |
| 37 | 37 | [wtforms.validators.Length(min=0, max=500)], |
| 38 | 38 | description=_('''This will be visible to users allowing your |
| 39 | 39 | application to authenticate as them.''')) |
| 40 | 40 | type = wtforms.SelectField(_('Type'), |
| 41 | | [wtforms.validators.Required()], |
| | 41 | [wtforms.validators.InputRequired()], |
| 42 | 42 | choices=[ |
| 43 | 43 | ('confidential', 'Confidential'), |
| 44 | 44 | ('public', 'Public')], |
diff --git a/mediagoblin/plugins/openid/forms.py b/mediagoblin/plugins/openid/forms.py
index f26024b..d47369d 100644
|
a
|
b
|
from mediagoblin.auth.tools import normalize_user_or_email_field
|
| 22 | 22 | class RegistrationForm(wtforms.Form): |
| 23 | 23 | openid = wtforms.HiddenField( |
| 24 | 24 | '', |
| 25 | | [wtforms.validators.Required()]) |
| | 25 | [wtforms.validators.InputRequired()]) |
| 26 | 26 | username = wtforms.TextField( |
| 27 | 27 | _('Username'), |
| 28 | | [wtforms.validators.Required(), |
| | 28 | [wtforms.validators.InputRequired(), |
| 29 | 29 | normalize_user_or_email_field(allow_email=False)]) |
| 30 | 30 | email = wtforms.TextField( |
| 31 | 31 | _('Email address'), |
| 32 | | [wtforms.validators.Required(), |
| | 32 | [wtforms.validators.InputRequired(), |
| 33 | 33 | normalize_user_or_email_field(allow_user=False)]) |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | class LoginForm(wtforms.Form): |
| 37 | 37 | openid = wtforms.TextField( |
| 38 | 38 | _('OpenID'), |
| 39 | | [wtforms.validators.Required(), |
| | 39 | [wtforms.validators.InputRequired(), |
| 40 | 40 | # Can openid's only be urls? |
| 41 | 41 | wtforms.validators.URL(message='Please enter a valid url.')]) |
diff --git a/mediagoblin/plugins/persona/forms.py b/mediagoblin/plugins/persona/forms.py
index 608be0c..7d63234 100644
|
a
|
b
|
from mediagoblin.auth.tools import normalize_user_or_email_field
|
| 22 | 22 | class RegistrationForm(wtforms.Form): |
| 23 | 23 | username = wtforms.TextField( |
| 24 | 24 | _('Username'), |
| 25 | | [wtforms.validators.Required(), |
| | 25 | [wtforms.validators.InputRequired(), |
| 26 | 26 | normalize_user_or_email_field(allow_email=False)]) |
| 27 | 27 | email = wtforms.TextField( |
| 28 | 28 | _('Email address'), |
| 29 | | [wtforms.validators.Required(), |
| | 29 | [wtforms.validators.InputRequired(), |
| 30 | 30 | normalize_user_or_email_field(allow_user=False)]) |
| 31 | 31 | persona_email = wtforms.HiddenField( |
| 32 | 32 | '', |
| 33 | | [wtforms.validators.Required(), |
| | 33 | [wtforms.validators.InputRequired(), |
| 34 | 34 | normalize_user_or_email_field(allow_user=False)]) |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | class EditForm(wtforms.Form): |
| 38 | 38 | email = wtforms.TextField( |
| 39 | 39 | _('Email address'), |
| 40 | | [wtforms.validators.Required(), |
| | 40 | [wtforms.validators.InputRequired(), |
| 41 | 41 | normalize_user_or_email_field(allow_user=False)]) |
diff --git a/mediagoblin/plugins/piwigo/forms.py b/mediagoblin/plugins/piwigo/forms.py
index fb04aa6..fd545a3 100644
|
a
|
b
|
_md5_validator = wtforms.validators.Regexp(r"^[0-9a-fA-F]{32}$")
|
| 34 | 34 | class AddForm(wtforms.Form): |
| 35 | 35 | original_sum = wtforms.TextField(None, |
| 36 | 36 | [_md5_validator, |
| 37 | | wtforms.validators.Required()]) |
| | 37 | wtforms.validators.InputRequired()]) |
| 38 | 38 | thumbnail_sum = wtforms.TextField(None, |
| 39 | 39 | [wtforms.validators.Optional(), |
| 40 | 40 | _md5_validator]) |
diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py
index e226464..6c0e8e9 100644
|
a
|
b
|
def get_submit_start_form(form, **kwargs):
|
| 59 | 59 | class AddCollectionForm(wtforms.Form): |
| 60 | 60 | title = wtforms.TextField( |
| 61 | 61 | _('Title'), |
| 62 | | [wtforms.validators.Length(min=0, max=500), wtforms.validators.Required()]) |
| | 62 | [wtforms.validators.Length(min=0, max=500), wtforms.validators.InputRequired()]) |
| 63 | 63 | description = wtforms.TextAreaField( |
| 64 | 64 | _('Description of this collection'), |
| 65 | 65 | description=_("""You can use |
diff --git a/mediagoblin/user_pages/forms.py b/mediagoblin/user_pages/forms.py
index eb786f4..1a09864 100644
|
a
|
b
|
from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
|
| 21 | 21 | class MediaCommentForm(wtforms.Form): |
| 22 | 22 | comment_content = wtforms.TextAreaField( |
| 23 | 23 | _('Comment'), |
| 24 | | [wtforms.validators.Required()], |
| | 24 | [wtforms.validators.InputRequired()], |
| 25 | 25 | description=_(u'You can use ' |
| 26 | 26 | u'<a href="http://daringfireball.net/projects/markdown/basics" target="_blank">' |
| 27 | 27 | u'Markdown</a> for formatting.')) |
| … |
… |
class MediaCollectForm(wtforms.Form):
|
| 53 | 53 | class CommentReportForm(wtforms.Form): |
| 54 | 54 | report_reason = wtforms.TextAreaField( |
| 55 | 55 | _('Reason for Reporting'), |
| 56 | | [wtforms.validators.Required()]) |
| | 56 | [wtforms.validators.InputRequired()]) |
| 57 | 57 | reporter_id = wtforms.HiddenField('') |
| 58 | 58 | |
| 59 | 59 | class MediaReportForm(wtforms.Form): |
| 60 | 60 | report_reason = wtforms.TextAreaField( |
| 61 | 61 | _('Reason for Reporting'), |
| 62 | | [wtforms.validators.Required()]) |
| | 62 | [wtforms.validators.InputRequired()]) |
| 63 | 63 | reporter_id = wtforms.HiddenField('') |