1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
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.
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.
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/>.
20 from mediagoblin
.tools
.translate
import fake_ugettext_passthrough
as _
23 class RegistrationForm(wtforms
.Form
):
24 username
= wtforms
.TextField(
26 [wtforms
.validators
.Required(),
27 wtforms
.validators
.Length(min=3, max=30),
28 wtforms
.validators
.Regexp(r
'^\w+$')])
29 password
= wtforms
.PasswordField(
31 [wtforms
.validators
.Required(),
32 wtforms
.validators
.Length(min=6, max=30),
33 wtforms
.validators
.EqualTo(
35 _('Passwords must match.'))])
36 confirm_password
= wtforms
.PasswordField(
37 _('Confirm password'),
38 [wtforms
.validators
.Required()],
40 u
"Type it again here to make sure there are no spelling mistakes."))
41 email
= wtforms
.TextField(
43 [wtforms
.validators
.Required(),
44 wtforms
.validators
.Email()])
47 class LoginForm(wtforms
.Form
):
48 username
= wtforms
.TextField(
50 [wtforms
.validators
.Required(),
51 wtforms
.validators
.Regexp(r
'^\w+$')])
52 password
= wtforms
.PasswordField(
54 [wtforms
.validators
.Required()])
57 class ForgotPassForm(wtforms
.Form
):
58 username
= wtforms
.TextField(
60 [wtforms
.validators
.Required()])
62 def validate_username(form
, field
):
63 if not (re
.match(r
'^\w+$', field
.data
) or
64 re
.match(r
'^.+@[^.].*\.[a-z]{2,10}$', field
.data
,
66 raise wtforms
.ValidationError(u
'Incorrect input')
69 class ChangePassForm(wtforms
.Form
):
70 password
= wtforms
.PasswordField(
72 [wtforms
.validators
.Required(),
73 wtforms
.validators
.Length(min=6, max=30),
74 wtforms
.validators
.EqualTo(
76 'Passwords must match.')])
77 confirm_password
= wtforms
.PasswordField(
79 [wtforms
.validators
.Required()])
80 userid
= wtforms
.HiddenField(
82 [wtforms
.validators
.Required()])
83 token
= wtforms
.HiddenField(
85 [wtforms
.validators
.Required()])