This has been an update to clean out the code a little bit. The primary change
authortilly-Q <nattilypigeonfowl@gmail.com>
Tue, 13 Aug 2013 22:38:00 +0000 (18:38 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Tue, 13 Aug 2013 22:38:00 +0000 (18:38 -0400)
I made was I added the method has_privilege (which takes a variable amount of
unicode privilege names as an argument) to the User model. This method allowed
for much cleaner checks as to whether or not a user has a privilege. Other-
wise, I also made it impossible for moderators to punish admins. I created a
new url path and three new pages for Users to look at filed reports and the
code of conduct for the mg instance.

=== Made reports on admins not resolvable by moderators:
--\   mediagoblin/moderation/views.py
--\   mediagoblin/templates/mediagoblin/moderation/report.html

=== Created new files for the new pages:
--\   mediagoblin/meta/__init__.py
--\   mediagoblin/meta/routing.py
--\   mediagoblin/meta/views.py
--\   mediagoblin/templates/mediagoblin/meta/code_of_conduct.html
--\   mediagoblin/templates/mediagoblin/meta/reports_details.html
--\   mediagoblin/templates/mediagoblin/meta/reports_panel.html
--\   mediagoblin/routing.py
--\   mediagoblin/static/css/base.css

=== Replaced vestigial methods of checking a user's privilege with the more
====== effective method has_privilege(u'privilege_name'):
--\   mediagoblin/db/models.py
--|   Added in the has_privilege method to the User class

--\   mediagoblin/db/migrations.py
--\   mediagoblin/db/models.py
--\   mediagoblin/decorators.py
--\   mediagoblin/edit/lib.py
--\   mediagoblin/edit/views.py
--\   mediagoblin/gmg_commands/users.py
--\   mediagoblin/moderation/views.py
--\   mediagoblin/templates/mediagoblin/base.html
--\   mediagoblin/templates/mediagoblin/user_pages/collection.html
--\   mediagoblin/templates/mediagoblin/user_pages/media.html
--\   mediagoblin/templates/mediagoblin/user_pages/user.html
--\   mediagoblin/templates/mediagoblin/utils/collection_gallery.html
--\   mediagoblin/user_pages/views.py

=== Minor UI changes
--\   mediagoblin/templates/mediagoblin/moderation/report_panel.html
--\   mediagoblin/templates/mediagoblin/moderation/user.html

=== Other Bugs:
--\   mediagoblin/tools/response.py
--\   mediagoblin/db/migrations.py

25 files changed:
mediagoblin/db/migrations.py
mediagoblin/db/models.py
mediagoblin/decorators.py
mediagoblin/edit/lib.py
mediagoblin/edit/views.py
mediagoblin/gmg_commands/users.py
mediagoblin/meta/__init__.py [new file with mode: 0644]
mediagoblin/meta/routing.py [new file with mode: 0644]
mediagoblin/meta/views.py [new file with mode: 0644]
mediagoblin/moderation/views.py
mediagoblin/routing.py
mediagoblin/static/css/base.css
mediagoblin/templates/mediagoblin/base.html
mediagoblin/templates/mediagoblin/meta/code_of_conduct.html [new file with mode: 0644]
mediagoblin/templates/mediagoblin/meta/reports_details.html [new file with mode: 0644]
mediagoblin/templates/mediagoblin/meta/reports_panel.html [new file with mode: 0644]
mediagoblin/templates/mediagoblin/moderation/report.html
mediagoblin/templates/mediagoblin/moderation/report_panel.html
mediagoblin/templates/mediagoblin/moderation/user.html
mediagoblin/templates/mediagoblin/user_pages/collection.html
mediagoblin/templates/mediagoblin/user_pages/media.html
mediagoblin/templates/mediagoblin/user_pages/user.html
mediagoblin/templates/mediagoblin/utils/collection_gallery.html
mediagoblin/tools/response.py
mediagoblin/user_pages/views.py

index 972908bebed1c286632668919b6e4ff008563f6b..e15b4ad316d182a0385780b31398b17c31ec03d4 100644 (file)
@@ -410,7 +410,7 @@ class ArchivedReport_v0(ReportBase_v0):
     __tablename__ = 'core__reports_archived'
     __mapper_args__ = {'polymorphic_identity': 'archived_report'}
 
-    id = Column('id',Integer, ForeignKey('core__reports.id'))
+    id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
     media_entry_id = Column(Integer, ForeignKey(MediaEntry.id))
     comment_id = Column(Integer, ForeignKey(MediaComment.id))
     resolver_id = Column(Integer, ForeignKey(User.id), nullable=False)
index 32d3135f3633917526180ca94592dd694f3e67ac..54b8f7398472b852c8831d2c612a5451cdc63261 100644 (file)
@@ -106,6 +106,16 @@ class User(Base, UserMixin):
         super(User, self).delete(**kwargs)
         _log.info('Deleted user "{0}" account'.format(self.username))
 
+    def has_privilege(self,*priv_names):
+        if len(priv_names) == 1:
+            priv = Privilege.query.filter(
+                Privilege.privilege_name==priv_names[0]).one()
+            return (priv in self.all_privileges)
+        elif len(priv_names) > 1:
+            return self.has_privilege(priv_names[0]) or \
+                self.has_privilege(*priv_names[1:])
+        return False
+
 
 class MediaEntry(Base, MediaEntryMixin):
     """
index 79b582c9ef48eac53d3577c6fa582a632c4effbe..d3a9647ec914e9ea49c0b6518da7badf744ba4e3 100644 (file)
@@ -35,11 +35,11 @@ def require_active_login(controller):
     @wraps(controller)
     def new_controller_func(request, *args, **kwargs):
         if request.user and \
-                request.user.status == u'needs_email_verification':
+                not request.user.has_privilege(u'active'):
             return redirect(
                 request, 'mediagoblin.user_pages.user_home',
                 user=request.user.username)
-        elif not request.user or request.user.status != u'active':
+        elif not request.user or not request.user.has_privilege(u'active'):
             next_url = urljoin(
                     request.urlgen('mediagoblin.auth.login',
                         qualified=True),
@@ -72,13 +72,9 @@ def user_has_privilege(privilege_name):
         @wraps(controller)
         def wrapper(request, *args, **kwargs):
             user_id = request.user.id
-            privileges_of_user = Privilege.query.filter(
-                Privilege.all_users.any(
-                User.id==user_id))
             if UserBan.query.filter(UserBan.user_id==user_id).count():
                 return render_user_banned(request)
-            elif not privileges_of_user.filter(
-                Privilege.privilege_name==privilege_name).count():
+            elif not request.user.has_privilege(privilege_name):
                 raise Forbidden()
 
             return controller(request, *args, **kwargs)
@@ -94,7 +90,7 @@ def user_may_delete_media(controller):
     @wraps(controller)
     def wrapper(request, *args, **kwargs):
         uploader_id = kwargs['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()
 
@@ -111,7 +107,7 @@ def user_may_alter_collection(controller):
     def wrapper(request, *args, **kwargs):
         creator_id = request.db.User.query.filter_by(
             username=request.matchdict['user']).first().id
-        if not (request.user.is_admin or
+        if not (request.user.has_privilege(u'admin') or
                 request.user.id == creator_id):
             raise Forbidden()
 
@@ -309,13 +305,8 @@ def require_admin_or_moderator_login(controller):
     """
     @wraps(controller)
     def new_controller_func(request, *args, **kwargs):
-        admin_privilege = Privilege.query.filter(
-            Privilege.privilege_name==u'admin').one()
-        moderator_privilege = Privilege.query.filter(
-            Privilege.privilege_name==u'moderator').one()
         if request.user and \
-            not admin_privilege in request.user.all_privileges and \
-                 not moderator_privilege in request.user.all_privileges:
+            not request.user.has_privilege(u'admin',u'moderator'):
 
             raise Forbidden()
         elif not request.user:
index aab537a095ea3c7bb4d34d788d8e9de614ac6467..6acebc96f31fb1b414c32c46a6dc14ad495fdd24 100644 (file)
@@ -19,6 +19,6 @@ def may_edit_media(request, media):
     """Check, if the request's user may edit the media details"""
     if media.uploader == request.user.id:
         return True
-    if request.user.is_admin:
+    if request.user.has_privilege(u'admin'):
         return True
     return False
index 6aa2acd94d5d3d5b1019b87968193f076af80e25..c6c3c03e1c4340a5642b9cd6e50576cecb74be91 100644 (file)
@@ -83,7 +83,7 @@ def edit_media(request, media):
 
             return redirect_obj(request, media)
 
-    if request.user.is_admin \
+    if request.user.has_privilege(u'admin') \
             and media.uploader != request.user.id \
             and request.method != 'POST':
         messages.add_message(
@@ -184,7 +184,7 @@ def legacy_edit_profile(request):
 def edit_profile(request, url_user=None):
     # admins may edit any user profile
     if request.user.username != url_user.username:
-        if not request.user.is_admin:
+        if not request.user.has_privilege(u'admin'):
             raise Forbidden(_("You can only edit your own profile."))
 
         # No need to warn again if admin just submitted an edited profile
@@ -326,7 +326,7 @@ def edit_collection(request, collection):
 
             return redirect_obj(request, collection)
 
-    if request.user.is_admin \
+    if request.user.has_privilege(u'admin') \
             and collection.creator != request.user.id \
             and request.method != 'POST':
         messages.add_message(
index 7e6fc5bc2be7d948c14be056ce42653f8b36a982..0002daad342f396d9c7de6cc918efea1036fe8ec 100644 (file)
@@ -85,7 +85,6 @@ def makeadmin(args):
     user = db.User.query.filter_by(
         username=unicode(args.username.lower())).one()
     if user:
-        user.is_admin = True
         user.all_privileges.append(
             db.Privilege.query.filter(
                 db.Privilege.privilege_name==u'admin').one()
diff --git a/mediagoblin/meta/__init__.py b/mediagoblin/meta/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/mediagoblin/meta/routing.py b/mediagoblin/meta/routing.py
new file mode 100644 (file)
index 0000000..e61bc06
--- /dev/null
@@ -0,0 +1,27 @@
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+meta_routes = [
+    ('mediagoblin.meta.code_of_conduct',
+        '/coc/',
+        'mediagoblin.meta.views:code_of_conduct'),
+    ('mediagoblin.meta.reports_panel',
+        '/reports/',
+        'mediagoblin.meta.views:public_reports_panel'),
+    ('mediagoblin.meta.reports_detail',
+        '/reports/<int:report_id>',
+        'mediagoblin.meta.views:public_reports_details')
+]
diff --git a/mediagoblin/meta/views.py b/mediagoblin/meta/views.py
new file mode 100644 (file)
index 0000000..3df0688
--- /dev/null
@@ -0,0 +1,33 @@
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from mediagoblin.tools.response import render_to_response
+
+
+def code_of_conduct(request):
+    return render_to_response(request,
+        'mediagoblin/meta/code_of_conduct.html',
+        {})
+
+def public_reports_panel(request):
+    return render_to_response(request,
+        'mediagoblin/meta/reports_panel.html',
+        {})
+
+def public_reports_details(request):
+    return render_to_response(request,
+        'mediagoblin/meta/reports_details.html',
+        {})
index 041cf5b3f2b8609240b65a98c1d086f2c7bdb5b4..d82eca7d8d17f43d52879e4a71f3fdf8fdd982d0 100644 (file)
@@ -74,15 +74,12 @@ def moderation_users_detail(request):
         ReportBase.discriminator=='archived_report').all()
     privileges = Privilege.query
     user_banned = UserBan.query.get(user.id)
-    user_privileges = user_privileges_to_dictionary(user.id)
-    requesting_user_privileges = user_privileges_to_dictionary(request.user.id)
 
     return render_to_response(
         request,
         'mediagoblin/moderation/user.html',
         {'user':user,
          'privileges': privileges,
-         'requesting_user_privileges':requesting_user_privileges,
          'reports':active_reports,
          'user_banned':user_banned})
 
@@ -121,7 +118,10 @@ def moderation_reports_detail(request):
             for s in report.reported_user.all_privileges 
     ]
 
-    if request.method == "POST" and form.validate():
+    if request.method == "POST" and form.validate() and not (
+        not request.user.has_privilege(u'admin') and
+        report.reported_user.has_privilege(u'admin')):
+
         user = User.query.get(form.targeted_user.data)
         return take_punitive_actions(request, form, report, user)
 
index c9377ad479310bad2e797577ece43742b999cf89..9686d10334609e5c4387cda387b586f7a7024df0 100644 (file)
@@ -20,6 +20,7 @@ from mediagoblin.tools.routing import add_route, mount, url_map
 from mediagoblin.tools.pluginapi import PluginManager
 from mediagoblin.moderation.routing import moderation_routes
 from mediagoblin.auth.routing import auth_routes
+from mediagoblin.meta.routing import meta_routes
 
 
 _log = logging.getLogger(__name__)
@@ -29,6 +30,7 @@ def get_url_map():
     add_route('index', '/', 'mediagoblin.views:root_view')
     mount('/auth', auth_routes)
     mount('/mod', moderation_routes)
+    mount('/meta', meta_routes)
 
     import mediagoblin.submit.routing
     import mediagoblin.user_pages.routing
@@ -37,6 +39,7 @@ def get_url_map():
     import mediagoblin.listings.routing
     import mediagoblin.notifications.routing
 
+
     for route in PluginManager().get_routes():
         add_route(*route)
 
index 338828d29a0ae5bad0244119dfdce268fa3c0b13..1293086df8a5771d00fd259f14f2a07369a8b1a2 100644 (file)
@@ -220,6 +220,7 @@ footer {
   color: #283F35;
 }
 
+
 .button_form {
   min-width: 99px;
   margin: 10px 0px 10px 15px;
@@ -615,7 +616,7 @@ table.media_panel th {
   text-align: left;
 }
 
-/* admin panels */
+/* moderator panels */
 
 table.admin_panel {
   width: 100%
@@ -655,6 +656,21 @@ table td.user_without_privilege {
   margin-left: 10px;
 }
 
+/* code of conduct */
+
+#code_of_conduct_list  {
+    margin-left:25px;
+    margin-bottom: 10px;
+}
+#code_of_conduct_list li {
+    margin-top:5px;
+}
+ol.nested_sublist{
+    margin: 5px 0 10px 25px;
+    font-size:80%;
+}
+
+
 /* ASCII art and code */
 
 @font-face {
index 31f0f0c37bc5e2d7eefcb7b353036bc185922217..6eaad70bde037d1f34fafcd1f6aeb3af4aeb8f2c 100644 (file)
               <a class="button_action" href="{{ request.urlgen('mediagoblin.submit.collection') }}">
                 {%- trans %}Create new collection{% endtrans -%}
               </a>
-              {% if request.user.is_admin %}
+              {% if request.user.has_privilege('admin','moderator') %}
                 <p>
-                  <span class="dropdown_title">Admin powers:</span>
+                  <span class="dropdown_title">Moderation powers:</span>
                   <a href="{{ request.urlgen('mediagoblin.moderation.media_panel') }}">
                     {%- trans %}Media processing panel{% endtrans -%}
                   </a>
diff --git a/mediagoblin/templates/mediagoblin/meta/code_of_conduct.html b/mediagoblin/templates/mediagoblin/meta/code_of_conduct.html
new file mode 100644 (file)
index 0000000..e8233ad
--- /dev/null
@@ -0,0 +1,46 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
+{% extends "mediagoblin/base.html" %}
+
+{% block title %}
+  Code of Conduct
+{% endblock %}
+
+{% block mediagoblin_content -%}
+<h2>{% trans %}Code of Conduct for this Website{% endtrans %}</h2>
+
+{# Suggested layout for this page:
+<ol id="code_of_conduct_list">
+  <li> Item #1 </li>
+  <li>
+    Item #2
+    <ol class="nested_sublist">
+      <li>Sub-Item #1</li>
+      <li>Sub-Item #2</li>
+      <li>
+        Sub-Item #3
+        <ol class="nested_sublist">
+          <li>Sub-Subitem #1</li>
+        </ol>
+      </li>
+    </ol>
+  </li>
+  <li>Item #3 </li>
+</ol>
+#}
+{% endblock -%}
diff --git a/mediagoblin/templates/mediagoblin/meta/reports_details.html b/mediagoblin/templates/mediagoblin/meta/reports_details.html
new file mode 100644 (file)
index 0000000..6fa5ae5
--- /dev/null
@@ -0,0 +1,17 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
diff --git a/mediagoblin/templates/mediagoblin/meta/reports_panel.html b/mediagoblin/templates/mediagoblin/meta/reports_panel.html
new file mode 100644 (file)
index 0000000..6fa5ae5
--- /dev/null
@@ -0,0 +1,17 @@
+{#
+# GNU MediaGoblin -- federated, autonomous media hosting
+# Copyright (C) 2011, 2012 MediaGoblin contributors.  See AUTHORS.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#}
index b912c71277c409dc66513b99078490a19d3b3cb2..04788f057a7c32da26a78528c542b95a1487b980 100644 (file)
       {{ report.report_content }}
     </div>
   </div>
-  {% if not report.is_archived_report() %}
+  {% if not report.is_archived_report() and not (report.reported_user.has_privilege('admin') and not request.user.has_privilege('admin')) %}
     <input type=button value=Resolve id=open_resolution_form />
     <form action="" method="POST" id=resolution_form>
       {{ wtforms_util.render_divs(form) }}
@@ -163,19 +163,6 @@ $(document).ready(function() {
                 $('#'+name).hide();                
             });
         });
-/*        $.each(hidden_input_names, function(key,name){
-            if ($.inArray(key, $('ul#action_to_resolve li input:checked').val())){
-                $.each(hidden_input_names[key], function(index,name){
-                    $('#'+name).show();
-                    $('label[for='+name+']').show();
-                });
-            } else {
-                $.each(hidden_input_names[key], function(index,name){
-                    $('#'+name).hide();
-                    $('label[for='+name+']').hide();
-                });
-            }
-        });*/
     });
     $("#user_banned_until").focus(function() {
         $(this).val("");
@@ -188,7 +175,7 @@ $(document).ready(function() {
     });
   });
   </script>
-  {% else %}
+  {% elif not (report.reported_user.has_privilege('admin')) %}
     <h2><img src="{{ request.staticdirect('/images/icon_clipboard.png') }}" 
              alt="Under a GNU LGPL v.3 or Creative Commons BY-SA 3.0 license.
                   Distributed by the GNOME project http://www.gnome.org" /> 
@@ -199,6 +186,9 @@ $(document).ready(function() {
     {% autoescape False %}
       <p>{{ report.result }}</p>
     {% endautoescape %}
+  {% else %}
+    <input type=button disabled=disabled value="Resolve This Report"/>
+    <p>You cannot take action against an administrator</p>
   {% endif %}
 {% endif %}
 {% endblock %}
index f3840e292d5e82963024764482d0b44dc6f74b82..2818eb80f37cc194dad777e5ea9aa89274e9f1a2 100644 (file)
         <td>{{ report.reported_user.username }}</td>
         <td>{{ report.created.strftime("%F %R") }}</td>
         <td>{{ report.reporter.username }}</td>
-        <td>{{ report.report_content }}</td>
+        <td>{{ report.report_content[:15] }}...</td>
       </tr>
     {% endfor %}
   </table>
index 3fb650638fec3df52279365a04e9413137e64a46..d8454d2d9c2a1a0cf12c0cef10a7bd09ed912e6e 100644 (file)
   {# If no user... #}
   {% if not user %}
     <p>{% trans %}Sorry, no such user found.{% endtrans %}</p>
-
   {# User exists, but needs verification #}
   {% elif user.status == "needs_email_verification" %}
     <div class="form_box">
     <h1>{% trans %}Email verification needed{% endtrans %}</h1>
-
     <p>
       {% trans -%}
         Someone has registered an account with this username, but it still has
 
   {# Active(?) (or at least verified at some point) user, horray! #}
   {% else %}
+    <a href="{{ request.urlgen('mediagoblin.moderation.users') }}"
+       class="return_to_panel button_action"
+       title="Return to Users Panel">
+      {% trans %}Return to Users Panel{% endtrans %}</a>
     <h1>
       {%- trans username=user.username %}{{ username }}'s profile{% endtrans -%}
     {% if user_banned and user_banned.expiration_date %}
@@ -64,7 +66,6 @@
       &mdash; Banned Indefinitely
     {% endif %}
     </h1>
-
     {% if not user.url and not user.bio %}
         <div class="profile_sidebar empty_space">
           <p>
@@ -76,7 +77,7 @@
       <div class="profile_sidebar">
         {% include "mediagoblin/utils/profile.html" %}
         {% if request.user and
-              (request.user.id == user.id or request.user.is_admin) %}
+              (request.user.id == user.id or request.user.has_privilege('admin')) %}
           <a href="{{ request.urlgen('mediagoblin.edit.profile',
                    user=user.username) }}">
             {%- trans %}Edit profile{% endtrans -%}
               <td class="user_without_privilege">
                 No{% endif %}
             </td>
-            {% if requesting_user_privileges.admin%}
-              <td>{% if privilege in user.all_privileges  %}
-                <input type=submit id="{{ privilege.privilege_name }}" class=submit_button value ="-" />{% else %}
-                <input type=submit id="{{ privilege.privilege_name }}" class=submit_button value ="+" />{% endif %}
+            {% if request.user.has_privilege('admin') %}
+              <td>
+                {% if privilege in user.all_privileges  %}
+                <input type=submit id="{{ privilege.privilege_name }}"
+                       class="submit_button button_action"
+                       value =" -" />
+                {% else %}
+                <input type=submit id="{{ privilege.privilege_name }}"
+                       class="submit_button button_action"
+                       value ="+" />
+                {% endif %}
               </td>
             {% endif %}
-
           </tr>
         {% endfor %}
     </table>
index 5a7baadde7ff49fa3817dc570be2736ed19a7104..87635dcb04c673834ce65377a9fa79786941e94d 100644 (file)
@@ -45,7 +45,7 @@
     {%- endtrans %}
   </h1>
   {% if request.user and (collection.creator == request.user.id or 
-                                                request.user.is_admin) %}
+                                                request.user.has_privilege(u'admin')) %}
     {% set edit_url = request.urlgen('mediagoblin.edit.edit_collection',
                                      user=collection.get_creator.username,
                                      collection=collection.slug) %}
index b10ef3be1e26461354533ad1dbfb48f98b70bc40..441452f211e9ad092815b9db277a468d9e349b45 100644 (file)
@@ -72,7 +72,7 @@
     </h2>
     {% 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.edit.edit_media',
                                  user= media.get_uploader.username,
                                  media_id=media.id) %}
     {%- if app_config['allow_attachments']
           and request.user
           and (media.uploader == request.user.id
-               or request.user.is_admin) %}
+               or request.user.has_privilege('admin')) %}
       {%- if not media.attachment_files|count %}
         <h3>{% trans %}Attachments{% endtrans %}</h3>
       {%- endif %}
index 71acd66c94253d0c2fcd565aa72f95a6b76b78dd..de92fb5e7f8f469fc5f9857c4584e94eab02107b 100644 (file)
       <div class="profile_sidebar">
         {% include "mediagoblin/utils/profile.html" %}
         {% if request.user and
-              (request.user.id == user.id or request.user.is_admin) %}
+              (request.user.id == user.id or request.user.has_privilege('admin')) %}
           <a href="{{ request.urlgen('mediagoblin.edit.profile',
                    user=user.username) }}">
             {%- trans %}Edit profile{% endtrans -%}
index dcc59244b7433b18081e9ed52dbf2805cf739849..24bf6832cfa7c818b55e36ac932bc6112210e96c 100644 (file)
@@ -39,7 +39,7 @@
             {% endif %}
            {% if request.user and
                   (item.in_collection.creator == request.user.id or 
-                  request.user.is_admin) %}
+                  request.user.has_privilege(u'admin')) %}
              {%- set remove_url=request.urlgen(
                                  'mediagoblin.user_pages.collection_item_confirm_remove',
                                  user=item.in_collection.get_creator.username,
index 8d9c02d4314ce38495c0bac35b418c884ef94846..54905a0e5fa1db653e35b9568f53114d278e82cf 100644 (file)
@@ -72,7 +72,7 @@ def render_user_banned(request):
     if datetime.now()>user_ban.expiration_date:
         user_ban.delete()
         redirect(request,
-            'mediagoblin.index')
+            'index')
     return render_to_response(request,
         'mediagoblin/banned.html',
         {'reason':user_ban.reason,
index 161a47e23c6eee8ae569fc543a5a41f4b76830c9..6c0bada256512c7166533f9852d0ee653e10f317 100644 (file)
@@ -299,7 +299,7 @@ def media_confirm_delete(request, media):
                 _("The media was not deleted because you didn't check that you were sure."))
             return redirect_obj(request, media)
 
-    if ((request.user.is_admin and
+    if ((request.user.has_privilege(u'admin') and
          request.user.id != media.uploader)):
         messages.add_message(
             request, messages.WARNING,
@@ -385,7 +385,7 @@ def collection_item_confirm_remove(request, collection_item):
 
         return redirect_obj(request, collection)
 
-    if ((request.user.is_admin and
+    if ((request.user.has_privilege(u'admin') and
          request.user.id != collection_item.in_collection.creator)):
         messages.add_message(
             request, messages.WARNING,
@@ -433,7 +433,7 @@ def collection_confirm_delete(request, collection):
 
             return redirect_obj(request, collection)
 
-    if ((request.user.is_admin and
+    if ((request.user.has_privilege(u'admin') and
          request.user.id != collection.creator)):
         messages.add_message(
             request, messages.WARNING,
@@ -594,7 +594,7 @@ def processing_panel(request):
     #
     # Make sure we have permission to access this user's panel.  Only
     # admins and this user herself should be able to do so.
-    if not (user.id == request.user.id or request.user.is_admin):
+    if not (user.id == request.user.id or request.user.has_privilege(u'admin')):
         # No?  Simply redirect to this user's homepage.
         return redirect(
             request, 'mediagoblin.user_pages.user_home',