1 # GNU MediaGoblin -- federated, autonomous media hosting
2 # Copyright (C) 2011, 2012 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/>.
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
23 class EditForm(wtforms
.Form
):
24 title
= wtforms
.TextField(
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(
34 [tag_length_validator
],
36 "Separate tags by commas."))
37 slug
= wtforms
.TextField(
39 [wtforms
.validators
.Required(message
=_("The slug can't be empty"))],
41 "The title part of this media's address. "
42 "You usually don't need to change this."))
43 license
= wtforms
.SelectField(
45 [wtforms
.validators
.Optional(),],
46 choices
=licenses_as_choices())
48 class EditProfileForm(wtforms
.Form
):
49 bio
= wtforms
.TextAreaField(
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(
57 [wtforms
.validators
.Optional(),
58 wtforms
.validators
.URL(message
=_("This address contains errors"))])
61 class EditAccountForm(wtforms
.Form
):
62 old_password
= wtforms
.PasswordField(
65 "Enter your old password to prove you own this account."))
66 new_password
= wtforms
.PasswordField(
69 wtforms
.validators
.Optional(),
70 wtforms
.validators
.Length(min=6, max=30)
73 license_preference
= wtforms
.SelectField(
74 _('License preference'),
76 wtforms
.validators
.Optional(),
77 wtforms
.validators
.AnyOf([lic
[0] for lic
in licenses_as_choices()]),
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"))
85 class EditAttachmentsForm(wtforms
.Form
):
86 attachment_name
= wtforms
.TextField(
88 attachment_file
= wtforms
.FileField(
91 class EditCollectionForm(wtforms
.Form
):
92 title
= wtforms
.TextField(
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(
102 [wtforms
.validators
.Required(message
=_("The slug can't be empty"))],
104 "The title part of this collection's address. "
105 "You usually don't need to change this."))