Convert blog plugin to use new privileges system
authorSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 12 Dec 2013 16:13:48 +0000 (17:13 +0100)
committerSebastian Spaeth <Sebastian@SSpaeth.de>
Thu, 12 Dec 2013 16:13:48 +0000 (17:13 +0100)
there is no user.is_admin anymore. Adapt to use the new privileges
system.

mediagoblin/media_types/blog/lib.py
mediagoblin/media_types/blog/views.py
mediagoblin/templates/mediagoblin/user_pages/blog_media.html
mediagoblin/user_pages/views.py

index 73ed6060766c85074e7edff1c0dce7762f644f9f..62696b55d6f5ad3028ad454971c861d8a175e242 100644 (file)
@@ -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
 
index b8e1d8457a1234773ad26f04bbbd83283f3dbe3a..cb34b4909a52b6a86406bf7f6dae21b7dee44a95 100644 (file)
@@ -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. "
index 25dd47836005d0d094d1cfd4cd238f685796dc20..c6eedee092cbf92f78ddf670a0114bfce6503788 100644 (file)
@@ -69,7 +69,7 @@
     </div>
         {% 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) %}
index c0553b189a7a916503f98bf30f3cc788a8b4ffdb..8adcd554f079dd42df6379af94fa9629f03d8c2a 100644 (file)
@@ -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()