From 04a95150646247abd13992b5c103a6d780d8861b Mon Sep 17 00:00:00 2001 From: Caleb Forbes Davis V Date: Fri, 8 Jul 2011 01:59:44 -0500 Subject: [PATCH] F360(tagging) - adds tag fields for submission, edit and display --- mediagoblin/edit/forms.py | 2 ++ mediagoblin/edit/views.py | 5 ++++- mediagoblin/submit/forms.py | 1 + mediagoblin/submit/views.py | 2 ++ mediagoblin/templates/mediagoblin/submit/start.html | 1 + mediagoblin/templates/mediagoblin/user_pages/media.html | 4 ++++ 6 files changed, 14 insertions(+), 1 deletion(-) diff --git a/mediagoblin/edit/forms.py b/mediagoblin/edit/forms.py index d5e7f0a9..b2d575cb 100644 --- a/mediagoblin/edit/forms.py +++ b/mediagoblin/edit/forms.py @@ -25,6 +25,8 @@ class EditForm(wtforms.Form): slug = wtforms.TextField( 'Slug') description = wtforms.TextAreaField('Description of this work') + tags = wtforms.TextField( + 'Tags') class EditProfileForm(wtforms.Form): bio = wtforms.TextAreaField('Bio', diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py index a3326b2d..96cb4be3 100644 --- a/mediagoblin/edit/views.py +++ b/mediagoblin/edit/views.py @@ -16,6 +16,7 @@ from webob import exc +from string import split from mediagoblin import messages from mediagoblin.util import render_to_response, redirect, clean_html @@ -35,7 +36,8 @@ def edit_media(request, media): form = forms.EditForm(request.POST, title = media['title'], slug = media['slug'], - description = media['description']) + description = media['description'], + tags = ' '.join(media['tags'])) if request.method == 'POST' and form.validate(): # Make sure there isn't already a MediaEntry with such a slug @@ -59,6 +61,7 @@ def edit_media(request, media): media['description'])) media['slug'] = request.POST['slug'] + media['tags'] = split(request.POST['tags']) media.save() return redirect(request, "mediagoblin.user_pages.media_home", diff --git a/mediagoblin/submit/forms.py b/mediagoblin/submit/forms.py index 3fd9ea49..0e0fd086 100644 --- a/mediagoblin/submit/forms.py +++ b/mediagoblin/submit/forms.py @@ -24,3 +24,4 @@ class SubmitStartForm(wtforms.Form): [wtforms.validators.Length(min=0, max=500)]) description = wtforms.TextAreaField('Description of this work') file = wtforms.FileField('File') + tags = wtforms.TextField('Tags') diff --git a/mediagoblin/submit/views.py b/mediagoblin/submit/views.py index 4c7476b0..cdd58786 100644 --- a/mediagoblin/submit/views.py +++ b/mediagoblin/submit/views.py @@ -16,6 +16,7 @@ from os.path import splitext from cgi import FieldStorage +from string import split from werkzeug.utils import secure_filename @@ -58,6 +59,7 @@ def submit_start(request): entry['media_type'] = u'image' # heh entry['uploader'] = request.user['_id'] + entry['tags'] = split(request.POST.get('tags')) # Save, just so we can get the entry id for the sake of using # it to generate the file path diff --git a/mediagoblin/templates/mediagoblin/submit/start.html b/mediagoblin/templates/mediagoblin/submit/start.html index 50c86afe..7bacb552 100644 --- a/mediagoblin/templates/mediagoblin/submit/start.html +++ b/mediagoblin/templates/mediagoblin/submit/start.html @@ -25,6 +25,7 @@

Submit yer media

{{ wtforms_util.render_field_div(submit_form.file) }} + {{ wtforms_util.render_field_div(submit_form.tags) }} {{ wtforms_util.render_field_div(submit_form.title) }} {{ wtforms_util.render_textarea_div(submit_form.description) }}
diff --git a/mediagoblin/templates/mediagoblin/user_pages/media.html b/mediagoblin/templates/mediagoblin/user_pages/media.html index 1484cc73..1c263880 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/media.html @@ -48,6 +48,10 @@ user= media.uploader().username) }}"> {{- media.uploader().username }}

+ +

+ {{ ' '.join(media.tags) }} +


Comments