aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAditi <aditi.iitr@gmail.com>2013-07-19 19:29:13 +0530
committerAditi <aditi.iitr@gmail.com>2013-07-19 19:29:13 +0530
commitfa5a13f8f31a3acae1b59732c34d2520d9cbe782 (patch)
tree5b2407d3156d9cfe5e4cbfe20f5df0f87d86f957
parent03e2a0f8067186e6f276581ff62152ad3ad62826 (diff)
downloadmediagoblin-fa5a13f8f31a3acae1b59732c34d2520d9cbe782.tar.lz
mediagoblin-fa5a13f8f31a3acae1b59732c34d2520d9cbe782.tar.xz
mediagoblin-fa5a13f8f31a3acae1b59732c34d2520d9cbe782.zip
Wrote blogpost_create view.
-rw-r--r--mediagoblin/media_types/blog/views.py49
1 files changed, 46 insertions, 3 deletions
diff --git a/mediagoblin/media_types/blog/views.py b/mediagoblin/media_types/blog/views.py
index 35ed5809..885594b1 100644
--- a/mediagoblin/media_types/blog/views.py
+++ b/mediagoblin/media_types/blog/views.py
@@ -41,6 +41,8 @@ from mediagoblin.tools.url import slugify
from mediagoblin.db.util import check_media_slug_used, check_collection_slug_used
from mediagoblin.db.models import User, Collection, MediaEntry
+from mediagoblin.notifications import add_comment_subscription
+
@require_active_login
def blog_edit(request):
@@ -99,9 +101,50 @@ def blog_edit(request):
'user': request.user,
'app_config': mg_globals.app_config})
else:
- pass
-
+ if request.method == 'POST' and form.validate():
+ blog.title = unicode(form.title.data)
+ blog.description = unicode(form.description.data)
+ blog.author = request.user.id
+ blog.generate_slug()
+
+ blog.save()
+ add_message(request, SUCCESS, "Your blog is updated.")
+ return redirect(request, "mediagoblin.user_pages.user_home",
+ user=request.user.username)
-
+@require_active_login
+def blogpost_create(request):
+ form = blog_forms.BlogPostEditForm(request.form, license=request.user.license_preference)
+
+ if request.method == 'POST' and form.validate():
+ blogpost = MediaEntry()
+ blogpost.media_type = 'blog_post'
+ blogpost.title = unicode(form.title.data)
+ blogpost.description = unicode(form.description.data)
+ blogpost.tags = convert_to_tag_list_of_dicts(form.tags.data)
+ blogpost.license = unicode(form.license.data) or None
+ blogpost.uploader = request.user.id
+ #blogpost.state = 'processed'
+
+ blogpost.generate_slug()
+
+ blogpost.save()
+
+ add_message(request, SUCCESS, _('Woohoo! Submitted!'))
+ add_comment_subscription(request.user, blogpost)
+ return redirect(request, "mediagoblin.user_pages.user_home",
+ user=request.user.username)
+
+ return render_to_response(
+ request,
+ 'mediagoblin/blog/blog_post_edit_create.html',
+ {'form': form,
+ 'app_config': mg_globals.app_config,
+ 'user': request.user.username})
+
+
+
+
+