It's 2012 all up in here
[mediagoblin.git] / mediagoblin / edit / forms.py
CommitLineData
aba81c9f 1# GNU MediaGoblin -- federated, autonomous media hosting
cf29e8a8 2# Copyright (C) 2011, 2012 MediaGoblin contributors. See AUTHORS.
aba81c9f
E
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/>.
16
aba81c9f 17import wtforms
4b1adc13 18
152a3bfa
AW
19from mediagoblin.tools.text import tag_length_validator, TOO_LONG_TAG_WARNING
20from mediagoblin.tools.translate import fake_ugettext_passthrough as _
25b48323 21from mediagoblin.tools.licenses import licenses_as_choices
aba81c9f
E
22
23class EditForm(wtforms.Form):
24 title = wtforms.TextField(
4b1adc13 25 _('Title'),
aba81c9f 26 [wtforms.validators.Length(min=0, max=500)])
9c196287
JS
27 description = wtforms.TextAreaField(
28 _('Description of this work'),
29 description=_("""You can use
30 <a href="http://daringfireball.net/projects/markdown/basics">
31 Markdown</a> for formatting."""))
909371cd 32 tags = wtforms.TextField(
4b1adc13 33 _('Tags'),
cee794a8
JS
34 [tag_length_validator],
35 description=_(
6f559060 36 "Separate tags by commas."))
7b80685a
CAW
37 slug = wtforms.TextField(
38 _('Slug'),
39 [wtforms.validators.Required(message=_("The slug can't be empty"))],
40 description=_(
c8071fa5 41 "The title part of this media's address. "
7b80685a 42 "You usually don't need to change this."))
25b48323
AW
43 license = wtforms.SelectField(
44 _('License'),
3c351460 45 [wtforms.validators.Optional(),],
25b48323 46 choices=licenses_as_choices())
630b57a3 47
48class EditProfileForm(wtforms.Form):
4b1adc13
CAW
49 bio = wtforms.TextAreaField(
50 _('Bio'),
9c196287 51 [wtforms.validators.Length(min=0, max=500)],
fafec727
JS
52 description=_("""You can use
53 <a href="http://daringfireball.net/projects/markdown/basics">
54 Markdown</a> for formatting."""))
630b57a3 55 url = wtforms.TextField(
4b1adc13 56 _('Website'),
20d82d60 57 [wtforms.validators.Optional(),
c8071fa5
JS
58 wtforms.validators.URL(message="""This address contains errors""")])
59
60
61class EditAccountForm(wtforms.Form):
4837b2f2
JK
62 old_password = wtforms.PasswordField(
63 _('Old password'),
c8071fa5
JS
64 [wtforms.validators.Required()],
65 description=_(
66 "Enter your old password to prove you own this account."))
4837b2f2 67 new_password = wtforms.PasswordField(
c8071fa5
JS
68 _('New password'),
69 [wtforms.validators.Required(),
49af00e4
E
70 wtforms.validators.Length(min=6, max=30)],
71 id="password")
3a8c3a38 72
7b80685a 73
3a8c3a38
JW
74class EditAttachmentsForm(wtforms.Form):
75 attachment_name = wtforms.TextField(
76 'Title')
77 attachment_file = wtforms.FileField(
78 'File')