Commit | Line | Data |
---|---|---|
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 | 17 | import wtforms |
4b1adc13 | 18 | |
89e1563f | 19 | from mediagoblin.tools.text import tag_length_validator |
665b9c42 | 20 | from mediagoblin.tools.translate import lazy_pass_to_ugettext as _ |
25b48323 | 21 | from mediagoblin.tools.licenses import licenses_as_choices |
515e3bd9 | 22 | from mediagoblin.auth.tools import normalize_user_or_email_field |
89e1563f | 23 | |
aba81c9f E |
24 | |
25 | class EditForm(wtforms.Form): | |
26 | title = wtforms.TextField( | |
4b1adc13 | 27 | _('Title'), |
aba81c9f | 28 | [wtforms.validators.Length(min=0, max=500)]) |
9c196287 JS |
29 | description = wtforms.TextAreaField( |
30 | _('Description of this work'), | |
31 | description=_("""You can use | |
32 | <a href="http://daringfireball.net/projects/markdown/basics"> | |
33 | Markdown</a> for formatting.""")) | |
909371cd | 34 | tags = wtforms.TextField( |
4b1adc13 | 35 | _('Tags'), |
cee794a8 JS |
36 | [tag_length_validator], |
37 | description=_( | |
6f559060 | 38 | "Separate tags by commas.")) |
7b80685a CAW |
39 | slug = wtforms.TextField( |
40 | _('Slug'), | |
41 | [wtforms.validators.Required(message=_("The slug can't be empty"))], | |
42 | description=_( | |
c8071fa5 | 43 | "The title part of this media's address. " |
7b80685a | 44 | "You usually don't need to change this.")) |
25b48323 AW |
45 | license = wtforms.SelectField( |
46 | _('License'), | |
3c351460 | 47 | [wtforms.validators.Optional(),], |
25b48323 | 48 | choices=licenses_as_choices()) |
630b57a3 | 49 | |
50 | class EditProfileForm(wtforms.Form): | |
4b1adc13 CAW |
51 | bio = wtforms.TextAreaField( |
52 | _('Bio'), | |
9c196287 | 53 | [wtforms.validators.Length(min=0, max=500)], |
fafec727 JS |
54 | description=_("""You can use |
55 | <a href="http://daringfireball.net/projects/markdown/basics"> | |
56 | Markdown</a> for formatting.""")) | |
630b57a3 | 57 | url = wtforms.TextField( |
4b1adc13 | 58 | _('Website'), |
20d82d60 | 59 | [wtforms.validators.Optional(), |
f646e2e1 | 60 | wtforms.validators.URL(message=_("This address contains errors"))]) |
c8071fa5 JS |
61 | |
62 | ||
63 | class EditAccountForm(wtforms.Form): | |
1e21471a | 64 | wants_comment_notification = wtforms.BooleanField( |
1e21471a | 65 | description=_("Email me when others comment on my media")) |
93d805ad | 66 | wants_notifications = wtforms.BooleanField( |
560fd638 | 67 | description=_("Enable insite notifications about events.")) |
dc4dfbde MH |
68 | license_preference = wtforms.SelectField( |
69 | _('License preference'), | |
70 | [ | |
71 | wtforms.validators.Optional(), | |
72 | wtforms.validators.AnyOf([lic[0] for lic in licenses_as_choices()]), | |
73 | ], | |
74 | choices=licenses_as_choices(), | |
75 | description=_('This will be your default license on upload forms.')) | |
3a8c3a38 | 76 | |
7b80685a | 77 | |
3a8c3a38 JW |
78 | class EditAttachmentsForm(wtforms.Form): |
79 | attachment_name = wtforms.TextField( | |
80 | 'Title') | |
81 | attachment_file = wtforms.FileField( | |
82 | 'File') | |
be5be115 | 83 | |
74ae6fb0 | 84 | |
be5be115 AW |
85 | class EditCollectionForm(wtforms.Form): |
86 | title = wtforms.TextField( | |
87 | _('Title'), | |
88 | [wtforms.validators.Length(min=0, max=500), wtforms.validators.Required(message=_("The title can't be empty"))]) | |
89 | description = wtforms.TextAreaField( | |
90 | _('Description of this collection'), | |
91 | description=_("""You can use | |
92 | <a href="http://daringfireball.net/projects/markdown/basics"> | |
93 | Markdown</a> for formatting.""")) | |
94 | slug = wtforms.TextField( | |
95 | _('Slug'), | |
96 | [wtforms.validators.Required(message=_("The slug can't be empty"))], | |
97 | description=_( | |
98 | "The title part of this collection's address. " | |
99 | "You usually don't need to change this.")) | |
39aa1db4 RE |
100 | |
101 | ||
102 | class ChangePassForm(wtforms.Form): | |
103 | old_password = wtforms.PasswordField( | |
104 | _('Old password'), | |
105 | [wtforms.validators.Required()], | |
106 | description=_( | |
107 | "Enter your old password to prove you own this account.")) | |
108 | new_password = wtforms.PasswordField( | |
109 | _('New password'), | |
110 | [wtforms.validators.Required(), | |
2ba76034 RE |
111 | wtforms.validators.Length(min=6, max=30)], |
112 | id="password") | |
402f4360 RE |
113 | |
114 | ||
115 | class ChangeEmailForm(wtforms.Form): | |
116 | new_email = wtforms.TextField( | |
117 | _('New email address'), | |
118 | [wtforms.validators.Required(), | |
119 | normalize_user_or_email_field(allow_user=False)]) | |
120 | password = wtforms.PasswordField( | |
121 | _('Password'), | |
122 | [wtforms.validators.Required()], | |
123 | description=_( | |
124 | "Enter your password to prove you own this account.")) | |
fffc5dcf | 125 | |
f0cfd339 | 126 | class MetaDataForm(wtforms.Form): |
127 | identifier = wtforms.TextField( | |
128 | _(u'Id')) | |
129 | value = wtforms.TextField( | |
130 | _(u'Value')) | |
131 | ||
fffc5dcf | 132 | class EditMetaDataForm(wtforms.Form): |
133 | media_metadata = wtforms.FieldList( | |
f0cfd339 | 134 | wtforms.FormField(MetaDataForm) |
135 | ) |