It's 2012 all up in here
[mediagoblin.git] / mediagoblin / edit / forms.py
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/>.
16
17 import wtforms
18
19 from mediagoblin.tools.text import tag_length_validator, TOO_LONG_TAG_WARNING
20 from mediagoblin.tools.translate import fake_ugettext_passthrough as _
21 from mediagoblin.tools.licenses import licenses_as_choices
22
23 class EditForm(wtforms.Form):
24 title = wtforms.TextField(
25 _('Title'),
26 [wtforms.validators.Length(min=0, max=500)])
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."""))
32 tags = wtforms.TextField(
33 _('Tags'),
34 [tag_length_validator],
35 description=_(
36 "Separate tags by commas."))
37 slug = wtforms.TextField(
38 _('Slug'),
39 [wtforms.validators.Required(message=_("The slug can't be empty"))],
40 description=_(
41 "The title part of this media's address. "
42 "You usually don't need to change this."))
43 license = wtforms.SelectField(
44 _('License'),
45 [wtforms.validators.Optional(),],
46 choices=licenses_as_choices())
47
48 class EditProfileForm(wtforms.Form):
49 bio = wtforms.TextAreaField(
50 _('Bio'),
51 [wtforms.validators.Length(min=0, max=500)],
52 description=_("""You can use
53 <a href="http://daringfireball.net/projects/markdown/basics">
54 Markdown</a> for formatting."""))
55 url = wtforms.TextField(
56 _('Website'),
57 [wtforms.validators.Optional(),
58 wtforms.validators.URL(message="""This address contains errors""")])
59
60
61 class EditAccountForm(wtforms.Form):
62 old_password = wtforms.PasswordField(
63 _('Old password'),
64 [wtforms.validators.Required()],
65 description=_(
66 "Enter your old password to prove you own this account."))
67 new_password = wtforms.PasswordField(
68 _('New password'),
69 [wtforms.validators.Required(),
70 wtforms.validators.Length(min=6, max=30)],
71 id="password")
72
73
74 class EditAttachmentsForm(wtforms.Form):
75 attachment_name = wtforms.TextField(
76 'Title')
77 attachment_file = wtforms.FileField(
78 'File')