From: tilly-Q Date: Tue, 30 Jul 2013 21:09:01 +0000 (-0400) Subject: This commit was the work I did fixing errors that cropped up from the merge. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=9d6e453f8fd337813c2933835aedff2949193fbe;p=mediagoblin.git This commit was the work I did fixing errors that cropped up from the merge. There were a few errors because of the switch from sqlalchemy 0.7 to 0.8 but I cleared them up. --- diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py index 53df7954..972908be 100644 --- a/mediagoblin/db/migrations.py +++ b/mediagoblin/db/migrations.py @@ -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' diff --git a/mediagoblin/db/util.py b/mediagoblin/db/util.py index 2a99d467..31fc49fb 100644 --- a/mediagoblin/db/util.py +++ b/mediagoblin/db/util.py @@ -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: diff --git a/mediagoblin/decorators.py b/mediagoblin/decorators.py index c9a1a78c..79b582c9 100644 --- a/mediagoblin/decorators.py +++ b/mediagoblin/decorators.py @@ -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: diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py index ad8263e7..7e6fc5bc 100644 --- a/mediagoblin/gmg_commands/users.py +++ b/mediagoblin/gmg_commands/users.py @@ -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: diff --git a/mediagoblin/moderation/tools.py b/mediagoblin/moderation/tools.py index 25e5dc63..b4daca15 100644 --- a/mediagoblin/moderation/tools.py +++ b/mediagoblin/moderation/tools.py @@ -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"
%s took away %s\'s %s privileges" % ( request.user.username, diff --git a/mediagoblin/moderation/views.py b/mediagoblin/moderation/views.py index 67928927..041cf5b3 100644 --- a/mediagoblin/moderation/views.py +++ b/mediagoblin/moderation/views.py @@ -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: diff --git a/mediagoblin/templates/mediagoblin/base.html b/mediagoblin/templates/mediagoblin/base.html index 575ddf42..31f0f0c3 100644 --- a/mediagoblin/templates/mediagoblin/base.html +++ b/mediagoblin/templates/mediagoblin/base.html @@ -118,6 +118,9 @@ {%- trans %}User management panel{% endtrans -%} + + {%- trans %}Report management panel{% endtrans -%} +

{% endif %} {% include 'mediagoblin/fragments/header_notifications.html' %} diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py index 06ea0ab0..161a47e2 100644 --- a/mediagoblin/user_pages/views.py +++ b/mediagoblin/user_pages/views.py @@ -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