Merge remote-tracking branch 'gsoc2016/Subtitle-1'
[mediagoblin.git] / mediagoblin / plugins / basic_auth / forms.py
CommitLineData
ba016fda
RE
1# GNU MediaGoblin -- federated, autonomous media hosting
2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
3#
4# This program is free software: you can redistribute it and/or modify
5# it under the terms of the GNU Affero General Public License as published by
6# the Free Software Foundation, either version 3 of the License, or
7# (at your option) any later version.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Affero General Public License for more details.
13#
14# You should have received a copy of the GNU Affero General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
ee355966
RE
16import wtforms
17
18from mediagoblin.tools.translate import lazy_pass_to_ugettext as _
0f3504e3 19from mediagoblin.auth.tools import normalize_user_or_email_field
ee355966
RE
20
21
22class RegistrationForm(wtforms.Form):
f4686cde 23 username = wtforms.StringField(
ee355966 24 _('Username'),
0742e11d 25 [wtforms.validators.InputRequired(),
ee355966
RE
26 normalize_user_or_email_field(allow_email=False)])
27 password = wtforms.PasswordField(
28 _('Password'),
0742e11d 29 [wtforms.validators.InputRequired(),
ee355966 30 wtforms.validators.Length(min=5, max=1024)])
f4686cde 31 email = wtforms.StringField(
ee355966 32 _('Email address'),
0742e11d 33 [wtforms.validators.InputRequired(),
ee355966
RE
34 normalize_user_or_email_field(allow_user=False)])
35
36
37class LoginForm(wtforms.Form):
f4686cde 38 username = wtforms.StringField(
ee355966 39 _('Username or Email'),
0742e11d 40 [wtforms.validators.InputRequired(),
4106eef3 41 normalize_user_or_email_field(is_login=True)])
ee355966 42 password = wtforms.PasswordField(
e4deacd9 43 _('Password'))
527b7e3b 44 stay_logged_in = wtforms.BooleanField(
0ec7ce4e
RE
45 label='',
46 description=_('Stay logged in'))
aeae6cc2
RE
47
48
49class ForgotPassForm(wtforms.Form):
f4686cde 50 username = wtforms.StringField(
aeae6cc2 51 _('Username or email'),
0742e11d 52 [wtforms.validators.InputRequired(),
aeae6cc2
RE
53 normalize_user_or_email_field()])
54
55
56class ChangeForgotPassForm(wtforms.Form):
57 password = wtforms.PasswordField(
58 'Password',
0742e11d 59 [wtforms.validators.InputRequired(),
aeae6cc2
RE
60 wtforms.validators.Length(min=5, max=1024)])
61 token = wtforms.HiddenField(
62 '',
0742e11d 63 [wtforms.validators.InputRequired()])
af665c4e
RE
64
65
66class ChangePassForm(wtforms.Form):
67 old_password = wtforms.PasswordField(
68 _('Old password'),
0742e11d 69 [wtforms.validators.InputRequired()],
af665c4e
RE
70 description=_(
71 "Enter your old password to prove you own this account."))
72 new_password = wtforms.PasswordField(
73 _('New password'),
0742e11d 74 [wtforms.validators.InputRequired(),
af665c4e
RE
75 wtforms.validators.Length(min=6, max=30)],
76 id="password")