From 391f4456a2034885d5af0760dc8070450e6aa4e2 Mon Sep 17 00:00:00 2001 From: Aditi Date: Mon, 22 Jul 2013 07:01:28 +0530 Subject: [PATCH] Create may_edit_blogpost function. --- mediagoblin/media_types/blog/lib.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mediagoblin/media_types/blog/lib.py b/mediagoblin/media_types/blog/lib.py index f628d27a..7de173ec 100644 --- a/mediagoblin/media_types/blog/lib.py +++ b/mediagoblin/media_types/blog/lib.py @@ -22,3 +22,9 @@ def check_blog_slug_used(author_id, slug, ignore_b_id=None): query = query.filter(Blog.id != ignore_b_id) does_exist = query.first() is not None return does_exist + +def may_edit_blogpost(request, blog): + if request.is_admin or request.user.id == blog.author: + return True + return False + -- 2.25.1