| 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 |
| 20 | from mediagoblin.tools.translate import lazy_pass_to_ugettext as _ |
| 21 | from mediagoblin.tools.licenses import licenses_as_choices |
| 22 | from mediagoblin.auth.forms import normalize_user_or_email_field |
| 23 | |
| 24 | |
| 25 | class EditForm(wtforms.Form): |
| 26 | title = wtforms.TextField( |
| 27 | _('Title'), |
| 28 | [wtforms.validators.Length(min=0, max=500)]) |
| 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.""")) |
| 34 | tags = wtforms.TextField( |
| 35 | _('Tags'), |
| 36 | [tag_length_validator], |
| 37 | description=_( |
| 38 | "Separate tags by commas.")) |
| 39 | slug = wtforms.TextField( |
| 40 | _('Slug'), |
| 41 | [wtforms.validators.Required(message=_("The slug can't be empty"))], |
| 42 | description=_( |
| 43 | "The title part of this media's address. " |
| 44 | "You usually don't need to change this.")) |
| 45 | license = wtforms.SelectField( |
| 46 | _('License'), |
| 47 | [wtforms.validators.Optional(),], |
| 48 | choices=licenses_as_choices()) |
| 49 | |
| 50 | class EditProfileForm(wtforms.Form): |
| 51 | bio = wtforms.TextAreaField( |
| 52 | _('Bio'), |
| 53 | [wtforms.validators.Length(min=0, max=500)], |
| 54 | description=_("""You can use |
| 55 | <a href="http://daringfireball.net/projects/markdown/basics"> |
| 56 | Markdown</a> for formatting.""")) |
| 57 | url = wtforms.TextField( |
| 58 | _('Website'), |
| 59 | [wtforms.validators.Optional(), |
| 60 | wtforms.validators.URL(message=_("This address contains errors"))]) |
| 61 | |
| 62 | |
| 63 | class EditAccountForm(wtforms.Form): |
| 64 | new_email = wtforms.TextField( |
| 65 | _('New email address'), |
| 66 | [wtforms.validators.Optional(), |
| 67 | normalize_user_or_email_field(allow_user=False)]) |
| 68 | wants_comment_notification = wtforms.BooleanField( |
| 69 | description=_("Email me when others comment on my media")) |
| 70 | wants_notifications = wtforms.BooleanField( |
| 71 | description=_("Enable/Disable insite notifications")) |
| 72 | license_preference = wtforms.SelectField( |
| 73 | _('License preference'), |
| 74 | [ |
| 75 | wtforms.validators.Optional(), |
| 76 | wtforms.validators.AnyOf([lic[0] for lic in licenses_as_choices()]), |
| 77 | ], |
| 78 | choices=licenses_as_choices(), |
| 79 | description=_('This will be your default license on upload forms.')) |
| 80 | |
| 81 | |
| 82 | class EditAttachmentsForm(wtforms.Form): |
| 83 | attachment_name = wtforms.TextField( |
| 84 | 'Title') |
| 85 | attachment_file = wtforms.FileField( |
| 86 | 'File') |
| 87 | |
| 88 | class EditCollectionForm(wtforms.Form): |
| 89 | title = wtforms.TextField( |
| 90 | _('Title'), |
| 91 | [wtforms.validators.Length(min=0, max=500), wtforms.validators.Required(message=_("The title can't be empty"))]) |
| 92 | description = wtforms.TextAreaField( |
| 93 | _('Description of this collection'), |
| 94 | description=_("""You can use |
| 95 | <a href="http://daringfireball.net/projects/markdown/basics"> |
| 96 | Markdown</a> for formatting.""")) |
| 97 | slug = wtforms.TextField( |
| 98 | _('Slug'), |
| 99 | [wtforms.validators.Required(message=_("The slug can't be empty"))], |
| 100 | description=_( |
| 101 | "The title part of this collection's address. " |
| 102 | "You usually don't need to change this.")) |
| 103 | |
| 104 | |
| 105 | class ChangePassForm(wtforms.Form): |
| 106 | old_password = wtforms.PasswordField( |
| 107 | _('Old password'), |
| 108 | [wtforms.validators.Required()], |
| 109 | description=_( |
| 110 | "Enter your old password to prove you own this account.")) |
| 111 | new_password = wtforms.PasswordField( |
| 112 | _('New password'), |
| 113 | [wtforms.validators.Required(), |
| 114 | wtforms.validators.Length(min=6, max=30)], |
| 115 | id="password") |