Fix blog extraction for get and post both type of requests.
authorAditi <aditi.iitr@gmail.com>
Thu, 25 Jul 2013 09:30:31 +0000 (15:00 +0530)
committerAditi <aditi.iitr@gmail.com>
Thu, 25 Jul 2013 09:30:31 +0000 (15:00 +0530)
mediagoblin/media_types/blog/views.py

index d4c78b4d97f8768a46501fb0070b09ece1128af7..91688f09fccbaf0916dabc8ab54eda39b056085b 100644 (file)
@@ -85,10 +85,10 @@ def blog_edit(request):
                         user=request.user.username)
 
 
-
+    #Blog already exists.
     else:
+        blog = Blog.query.filter_by(slug=blog_slug).first()
         if request.method == 'GET':
-            blog = Blog.query.filter_by(slug=blog_slug).first()
             defaults = dict(
                 title = blog.title,
                 description = blog.description,
@@ -119,8 +119,11 @@ def blogpost_create(request):
     
 
     form = blog_forms.BlogPostEditForm(request.form, license=request.user.license_preference)
-     
+    
     if request.method == 'POST' and form.validate():
+       
+        _log.info(request.form['status'])
+           
         blog_slug = request.matchdict.get('blog_slug')
         blog = request.db.Blog.query.filter_by(slug=blog_slug,
             author=request.user.id).first()
@@ -220,9 +223,7 @@ def blog_dashboard(request):
         'blog_slug':blog_slug,
         'blog':blog,
         'blog_post_count':blog_post_count
-        })
-
-                                                            
+        })