From: Aditi Date: Tue, 30 Jul 2013 09:56:11 +0000 (+0530) Subject: Add feature: redirect to 404 error if blog or blog post slug do not exist. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=b5ae96851c12b7fdc81727ee385900b4c8324ee3;p=mediagoblin.git Add feature: redirect to 404 error if blog or blog post slug do not exist. --- diff --git a/mediagoblin/media_types/blog/views.py b/mediagoblin/media_types/blog/views.py index 1d7788cb..85e6aed2 100644 --- a/mediagoblin/media_types/blog/views.py +++ b/mediagoblin/media_types/blog/views.py @@ -82,8 +82,9 @@ def blog_edit(request): blog_slug=blog.slug) else: add_message(request, ERROR, "You can not create any more blogs") - return redirect(request, "mediagoblin.user_pages.user_home", - user=request.user.username) + return redirect(request, "mediagoblin.media_types.blog.blog-dashboard", + user=request.user.username, + blog_slug=blog.slug) #Blog already exists. @@ -167,9 +168,13 @@ def blogpost_create(request): def blogpost_edit(request): blog_slug = request.matchdict.get('blog_slug', None) blog_post_slug = request.matchdict.get('blog_post_slug', None) + blogpost = request.db.MediaEntry.query.filter_by(slug=blog_post_slug, uploader=request.user.id).first() blog = request.db.Blog.query.filter_by(slug=blog_slug, author=request.user.id).first() - + + if not blogpost or not blog: + return render_404(request) + defaults = dict( title = blogpost.title, description = blogpost.description, @@ -201,11 +206,17 @@ def blogpost_edit(request): @require_active_login def blog_dashboard(request): + + url_user = request.matchdict.get('user') blog_posts_list = [] blog_slug = request.matchdict.get('blog_slug') _log.info(blog_slug) blog = request.db.Blog.query.filter_by(slug=blog_slug).first() + + if not blog: + return render_404(request) + blog_post_data = request.db.BlogPostData.query.filter_by(blog=blog.id).all() for each_blog_post_data in blog_post_data: