Merge branch 'master' into joar-skip_transcoding
[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 description=_(
65 "Enter your old password to prove you own this account."))
66 new_password = wtforms.PasswordField(
67 _('New password'),
68 [
69 wtforms.validators.Optional(),
70 wtforms.validators.Length(min=6, max=30)
71 ],
72 id="password")
73 license_preference = wtforms.SelectField(
74 _('License preference'),
75 [
76 wtforms.validators.Optional(),
77 wtforms.validators.AnyOf([lic[0] for lic in licenses_as_choices()]),
78 ],
79 choices=licenses_as_choices(),
80 description=_('This will be your default license on upload forms.'))
81 wants_comment_notification = wtforms.BooleanField(
82 label=_("Email me when others comment on my media"))
83
84
85 class EditAttachmentsForm(wtforms.Form):
86 attachment_name = wtforms.TextField(
87 'Title')
88 attachment_file = wtforms.FileField(
89 'File')
90
91 class EditCollectionForm(wtforms.Form):
92 title = wtforms.TextField(
93 _('Title'),
94 [wtforms.validators.Length(min=0, max=500), wtforms.validators.Required(message=_("The title can't be empty"))])
95 description = wtforms.TextAreaField(
96 _('Description of this collection'),
97 description=_("""You can use
98 <a href="http://daringfireball.net/projects/markdown/basics">
99 Markdown</a> for formatting."""))
100 slug = wtforms.TextField(
101 _('Slug'),
102 [wtforms.validators.Required(message=_("The slug can't be empty"))],
103 description=_(
104 "The title part of this collection's address. "
105 "You usually don't need to change this."))