From 39fbb83490ccb30858d62f35f6a1f4c1813b23d2 Mon Sep 17 00:00:00 2001 From: Sebastian Spaeth Date: Thu, 12 Dec 2013 17:13:48 +0100 Subject: [PATCH] Convert blog plugin to use new privileges system there is no user.is_admin anymore. Adapt to use the new privileges system. --- mediagoblin/media_types/blog/lib.py | 2 +- mediagoblin/media_types/blog/views.py | 6 +++--- .../templates/mediagoblin/user_pages/blog_media.html | 2 +- mediagoblin/user_pages/views.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mediagoblin/media_types/blog/lib.py b/mediagoblin/media_types/blog/lib.py index 73ed6060..62696b55 100644 --- a/mediagoblin/media_types/blog/lib.py +++ b/mediagoblin/media_types/blog/lib.py @@ -24,7 +24,7 @@ def check_blog_slug_used(author_id, slug, ignore_b_id=None): return does_exist def may_edit_blogpost(request, blog): - if request.user.is_admin or request.user.id == blog.author: + if request.user.has_privilege(u'admin') or request.user.id == blog.author: return True return False diff --git a/mediagoblin/media_types/blog/views.py b/mediagoblin/media_types/blog/views.py index b8e1d845..cb34b490 100644 --- a/mediagoblin/media_types/blog/views.py +++ b/mediagoblin/media_types/blog/views.py @@ -221,7 +221,7 @@ def blog_dashboard(request, page): blogs = request.db.Blog.query.filter_by(author=user.id) config = pluginapi.get_config('mediagoblin.media_types.blog') max_blog_count = config['max_blog_count'] - if (request.user and request.user.id == user.id) or (request.user and request.user.is_admin): + if request.user and (request.user.id == user.id or request.user.has_privilege(u'admin')): if blog_slug: blog = blogs.filter(Blog.slug==blog_slug).first() if not blog: @@ -316,7 +316,7 @@ def blog_delete(request, **kwargs): return render_404(reequest) form = blog_forms.ConfirmDeleteForm(request.form) - if request.user.id == blog.author or request.user.is_admin: + if request.user.id == blog.author or request.user.has_privilege(u'admin'): if request.method == 'POST' and form.validate(): if form.confirm.data is True: blog.delete() @@ -331,7 +331,7 @@ def blog_delete(request, **kwargs): return redirect(request, "mediagoblin.media_types.blog.blog_admin_dashboard", user=request.user.username) else: - if request.user.is_admin: + if request.user.has_privilege(u'admin'): add_message( request, WARNING, _("You are about to delete another user's Blog. " diff --git a/mediagoblin/templates/mediagoblin/user_pages/blog_media.html b/mediagoblin/templates/mediagoblin/user_pages/blog_media.html index 25dd4783..c6eedee0 100644 --- a/mediagoblin/templates/mediagoblin/user_pages/blog_media.html +++ b/mediagoblin/templates/mediagoblin/user_pages/blog_media.html @@ -69,7 +69,7 @@ {% if request.user and (media.uploader == request.user.id or - request.user.is_admin) %} + request.user.has_privilege('admin')) %} {% set edit_url = request.urlgen('mediagoblin.media_types.blog.blogpost.edit', blog_slug=media.media_manager.get_blog_by_blogpost().slug, user=request.user.username, blog_post_slug=media.slug) %} diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index c0553b18..8adcd554 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -305,7 +305,7 @@ def media_confirm_delete(request): return render_404(request) uploader_id = media.uploader - if not (request.user.is_admin or + if not (request.user.has_privilege(u'admin') or request.user.id == uploader_id): raise Forbidden() -- 2.25.1