This commit was the work I did fixing errors that cropped up from the merge.
authortilly-Q <nattilypigeonfowl@gmail.com>
Tue, 30 Jul 2013 21:09:01 +0000 (17:09 -0400)
committertilly-Q <nattilypigeonfowl@gmail.com>
Thu, 1 Aug 2013 00:11:26 +0000 (20:11 -0400)
There were a few errors because of the switch from sqlalchemy 0.7 to 0.8 but I
cleared them up.

mediagoblin/db/migrations.py
mediagoblin/db/util.py
mediagoblin/decorators.py
mediagoblin/gmg_commands/users.py
mediagoblin/moderation/tools.py
mediagoblin/moderation/views.py
mediagoblin/templates/mediagoblin/base.html
mediagoblin/user_pages/views.py

index 53df795458da2e6e4229d3b9233825520e87043f..972908bebed1c286632668919b6e4ff008563f6b 100644 (file)
@@ -404,7 +404,7 @@ class MediaReport_v0(ReportBase_v0):
     __mapper_args__ = {'polymorphic_identity': 'media_report'}
 
     id = Column('id',Integer, ForeignKey('core__reports.id'), primary_key=True)
-    media_entry_id = Column(Integer, ForeignKey(MediaEntry.i
+    media_entry_id = Column(Integer, ForeignKey(MediaEntry.id), nullable=False)
 
 class ArchivedReport_v0(ReportBase_v0):
     __tablename__ = 'core__reports_archived'
index 2a99d46738d9d662f9378eef9a1bbc1e78068f4f..31fc49fb3ec2d9154b56bc2520e3b9bdcc7a1265 100644 (file)
@@ -77,8 +77,9 @@ def user_privileges_to_dictionary(user_id):
     privilege_dictionary = {}
     user = User.query.get(user_id)
     users_privileges = [p_item.privilege_name for p_item in user.all_privileges]
-    for privilege_name in FOUNDATIONS[Privilege]:
-        privilege_name = privilege_name[0]
+    #TODO update this to account for plugins that may add foundations
+    for privilege in FOUNDATIONS[Privilege]:
+        privilege_name = privilege['privilege_name']
         if privilege_name in users_privileges:
             privilege_dictionary[privilege_name]=True
         else:
index c9a1a78c0eddc53dcb75b3eaf51e84d7452501bd..79b582c9ef48eac53d3577c6fa582a632c4effbe 100644 (file)
@@ -22,9 +22,9 @@ from werkzeug.urls import url_quote
 
 from mediagoblin import mg_globals as mgg
 from mediagoblin import messages
-from mediagoblin.db.models import MediaEntry, User, MediaComment,
-                                                       UserBan
-from mediagoblin.tools.response import redirect, render_404
+from mediagoblin.db.models import (MediaEntry, User, MediaComment,
+                                                       UserBan, Privilege)
+from mediagoblin.tools.response import redirect, render_404, render_user_banned
 from mediagoblin.tools.translate import pass_to_ugettext as _
 
 
@@ -309,8 +309,10 @@ def require_admin_or_moderator_login(controller):
     """
     @wraps(controller)
     def new_controller_func(request, *args, **kwargs):
-        admin_privilege = Privilege.one({'privilege_name':u'admin'})
-        moderator_privilege = Privilege.one({'privilege_name':u'moderator'})
+        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:
index ad8263e762fb26aac87c9e4530a24c9ab4fde6a0..7e6fc5bc2be7d948c14be056ce42653f8b36a982 100644 (file)
@@ -56,11 +56,15 @@ def adduser(args):
         entry.status = u'active'
         entry.email_verified = True
         default_privileges = [ 
-            db.Privilege.one({'privilege_name':u'commenter'}),
-            db.Privilege.one({'privilege_name':u'uploader'}),
-            db.Privilege.one({'privilege_name':u'reporter'}),
-            db.Privilege.one({'privilege_name':u'active'})
-]
+            db.Privilege.query.filter(
+                db.Privilege.privilege_name==u'commenter').one(),
+            db.Privilege.query.filter(
+                db.Privilege.privilege_name==u'uploader').one(),
+            db.Privilege.query.filter(
+                db.Privilege.privilege_name==u'reporter').one(),
+            db.Privilege.query.filter(
+                db.Privilege.privilege_name==u'active').one()
+        ]
         entry.all_privileges = default_privileges
         entry.save()
 
@@ -83,9 +87,9 @@ def makeadmin(args):
     if user:
         user.is_admin = True
         user.all_privileges.append(
-            db.Privilege.one({
-                'privilege_name':u'admin'})
-            )
+            db.Privilege.query.filter(
+                db.Privilege.privilege_name==u'admin').one()
+        )
         user.save()
         print 'The user is now Admin'
     else:
index 25e5dc63a0e0d201571c80451acba812eae4ea23..b4daca152974f23e8c77e091cf8c64cceef112a9 100644 (file)
@@ -31,7 +31,8 @@ def take_punitive_actions(request, form, report, user):
         # punitive actions that a moderator could take.
         if u'takeaway' in form.action_to_resolve.data:
             for privilege_name in form.take_away_privileges.data:
-                privilege = Privilege.one({u'privilege_name':privilege_name})
+                privilege = Privilege.query.filter(
+                    Privilege.privilege_name==privilege_name).one()
                 form.resolution_content.data += \
                     u"<br>%s took away %s\'s %s privileges" % (
                         request.user.username,
index 67928927b58772a6985c1637f2ef171e9b54dfed..041cf5b3f2b8609240b65a98c1d086f2c7bdb5b4 100644 (file)
@@ -116,7 +116,10 @@ def moderation_reports_detail(request):
     form = moderation_forms.ReportResolutionForm(request.form)
     report = ReportBase.query.get(request.matchdict['report_id'])
 
-    form.take_away_privileges.choices = [(s.privilege_name,s.privilege_name.title()) for s in report.reported_user.all_privileges]
+    form.take_away_privileges.choices = [
+        (s.privilege_name,s.privilege_name.title()) \
+            for s in report.reported_user.all_privileges 
+    ]
 
     if request.method == "POST" and form.validate():
         user = User.query.get(form.targeted_user.data)
@@ -139,7 +142,8 @@ def give_or_take_away_privilege(request, url_user):
     '''
     form = moderation_forms.PrivilegeAddRemoveForm(request.form)
     if request.method == "POST" and form.validate():
-        privilege = Privilege.one({'privilege_name':form.privilege_name.data})
+        privilege = Privilege.query.filter(
+            Privilege.privilege_name==form.privilege_name.data).one()
         if privilege in url_user.all_privileges:
             url_user.all_privileges.remove(privilege)
         else:      
index 575ddf42ec9246397b2dd0a7875123dbbf3521df..31f0f0c37bc5e2d7eefcb7b353036bc185922217 100644 (file)
                   <a href="{{ request.urlgen('mediagoblin.moderation.users') }}">
                     {%- trans %}User management panel{% endtrans -%}
                   </a>
+                  <a href="{{ request.urlgen('mediagoblin.moderation.reports') }}">
+                    {%- trans %}Report management panel{% endtrans -%}
+                  </a>
                 </p>
               {% endif %}
               {% include 'mediagoblin/fragments/header_notifications.html' %}
index 06ea0ab0dbcc1ba28b9c7cda5cc9da0dd036eb9a..161a47e23c6eee8ae569fc543a5a41f4b76830c9 100644 (file)
@@ -27,7 +27,7 @@ from mediagoblin.tools.translate import pass_to_ugettext as _
 from mediagoblin.tools.pagination import Pagination
 from mediagoblin.user_pages import forms as user_forms
 from mediagoblin.user_pages.lib import (send_comment_email,
-       add_media_to_collection)
+       add_media_to_collection, build_report_object)
 from mediagoblin.notifications import trigger_notification, \
     add_comment_subscription, mark_comment_notification_seen