From b4997540dcc7b75441e9b10ee6dcac32cc2708be Mon Sep 17 00:00:00 2001 From: Jessica Tallon Date: Mon, 24 Aug 2015 18:28:41 +0200 Subject: Fix some unit tests and bugs This fixes a lot of the issues with the LocalUser changes that were merged recently. There was a problem where the attributes of LocalUser were not being eagerly loaded and because the Session was detached an exception was being raised when they were accessed. This also fixes some typo's which were introduced. Finally this adds a temporary fix for a potential SQLAlchemy bug, this is a bug where doing: User.query.filter(LocalUser.username == "some_username").first() does NOT yeild a user with the username "some_username" but all users on the site. The temp fix is to just query the LocalUser, this should be resolved when bug is confirmed and fixed upstream. --- mediagoblin/moderation/tools.py | 6 +++--- mediagoblin/moderation/views.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'mediagoblin/moderation') diff --git a/mediagoblin/moderation/tools.py b/mediagoblin/moderation/tools.py index 56ef9449..d1fedb0e 100644 --- a/mediagoblin/moderation/tools.py +++ b/mediagoblin/moderation/tools.py @@ -122,7 +122,7 @@ def take_away_privileges(user,*privileges): if len(privileges) == 1: privilege = Privilege.query.filter( Privilege.privilege_name==privileges[0]).first() - user = User.query.filter( + user = LocalUser.query.filter( LocalUser.username==user ).first() if privilege in user.all_privileges: @@ -155,8 +155,8 @@ def give_privileges(user,*privileges): if len(privileges) == 1: privilege = Privilege.query.filter( Privilege.privilege_name==privileges[0]).first() - user = User.query.filter( - LoclUser.username==user + user = LocalUser.query.filter( + LocalUser.username==user ).first() if privilege not in user.all_privileges: user.all_privileges.append(privilege) diff --git a/mediagoblin/moderation/views.py b/mediagoblin/moderation/views.py index b99f4660..a73537d6 100644 --- a/mediagoblin/moderation/views.py +++ b/mediagoblin/moderation/views.py @@ -79,7 +79,7 @@ def moderation_users_detail(request): ''' Shows details about a particular user. ''' - user = User.query.filter( + user = LocalUser.query.filter( LocalUser.username==request.matchdict['user'] ).first() active_reports = user.reports_filed_on.filter( -- cgit v1.2.3