aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/edit
diff options
context:
space:
mode:
authorChristopher Allan Webber <cwebber@dustycloud.org>2011-08-10 19:53:37 -0500
committerChristopher Allan Webber <cwebber@dustycloud.org>2011-08-10 19:53:37 -0500
commit852d5bb2387706c11925fa0c2abe4a1f34708f16 (patch)
treedf5e6a3108d2ba007112b558ff65bbfabd88020c /mediagoblin/edit
parent6b9ee0ca13b99ee20f9d0c680a950c6a7494a5a0 (diff)
parent6d794f268bb1f5d3cc56c5f0dc902571d48ebeac (diff)
downloadmediagoblin-852d5bb2387706c11925fa0c2abe4a1f34708f16.tar.lz
mediagoblin-852d5bb2387706c11925fa0c2abe4a1f34708f16.tar.xz
mediagoblin-852d5bb2387706c11925fa0c2abe4a1f34708f16.zip
Merge branch 'master' into processing
Diffstat (limited to 'mediagoblin/edit')
-rw-r--r--mediagoblin/edit/__init__.py17
-rw-r--r--mediagoblin/edit/forms.py19
-rw-r--r--mediagoblin/edit/views.py19
3 files changed, 43 insertions, 12 deletions
diff --git a/mediagoblin/edit/__init__.py b/mediagoblin/edit/__init__.py
index e69de29b..a8eeb5ed 100644
--- a/mediagoblin/edit/__init__.py
+++ b/mediagoblin/edit/__init__.py
@@ -0,0 +1,17 @@
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011 Free Software Foundation, Inc
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py
index 0ed52af1..2f3ed203 100644
--- a/mediagoblin/edit/forms.py
+++ b/mediagoblin/edit/forms.py
@@ -17,20 +17,27 @@
import wtforms
+from mediagoblin.util import tag_length_validator, TOO_LONG_TAG_WARNING
+from mediagoblin.util import fake_ugettext_passthrough as _
+
class EditForm(wtforms.Form):
title = wtforms.TextField(
- 'Title',
+ _('Title'),
[wtforms.validators.Length(min=0, max=500)])
slug = wtforms.TextField(
- 'Slug',
- [wtforms.validators.Required(message="The slug can't be empty")])
+ _('Slug'),
+ [wtforms.validators.Required(message=_("The slug can't be empty"))])
description = wtforms.TextAreaField('Description of this work')
+ tags = wtforms.TextField(
+ _('Tags'),
+ [tag_length_validator])
class EditProfileForm(wtforms.Form):
- bio = wtforms.TextAreaField('Bio',
+ bio = wtforms.TextAreaField(
+ _('Bio'),
[wtforms.validators.Length(min=0, max=500)])
url = wtforms.TextField(
- 'Website',
+ _('Website'),
[wtforms.validators.Optional(),
- wtforms.validators.URL(message='Improperly formed URL')])
+ wtforms.validators.URL(message=_('Improperly formed URL'))])
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index f372fbb9..0b1a98f1 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -16,10 +16,14 @@
from webob import exc
+from string import split
from mediagoblin import messages
+from mediagoblin import mg_globals
from mediagoblin.util import (
- render_to_response, redirect, cleaned_markdown_conversion)
+ render_to_response, redirect, clean_html, convert_to_tag_list_of_dicts,
+ media_tags_as_string, cleaned_markdown_conversion)
+from mediagoblin.util import pass_to_ugettext as _
from mediagoblin.edit import forms
from mediagoblin.edit.lib import may_edit_media
from mediagoblin.decorators import require_active_login, get_user_media_entry
@@ -34,7 +38,8 @@ def edit_media(request, media):
form = forms.EditForm(request.POST,
title = media['title'],
slug = media['slug'],
- description = media['description'])
+ description = media['description'],
+ tags = media_tags_as_string(media['tags']))
if request.method == 'POST' and form.validate():
# Make sure there isn't already a MediaEntry with such a slug
@@ -46,11 +51,13 @@ def edit_media(request, media):
if existing_user_slug_entries:
form.slug.errors.append(
- u'An entry with that slug already exists for this user.')
+ _(u'An entry with that slug already exists for this user.'))
else:
media['title'] = request.POST['title']
media['description'] = request.POST.get('description')
-
+ media['tags'] = convert_to_tag_list_of_dicts(
+ request.POST.get('tags'))
+
media['description_html'] = cleaned_markdown_conversion(
media['description'])
@@ -65,7 +72,7 @@ def edit_media(request, media):
and request.method != 'POST':
messages.add_message(
request, messages.WARNING,
- "You are editing another user's media. Proceed with caution.")
+ _("You are editing another user's media. Proceed with caution."))
return render_to_response(
@@ -86,7 +93,7 @@ def edit_profile(request):
if request.method != 'POST':
messages.add_message(
request, messages.WARNING,
- "You are editing a user's profile. Proceed with caution.")
+ _("You are editing a user's profile. Proceed with caution."))
else:
user = request.user