aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands
diff options
context:
space:
mode:
authorJessica Tallon <tsyesika@tsyesika.se>2015-08-24 18:28:41 +0200
committerJessica Tallon <tsyesika@tsyesika.se>2015-08-24 21:07:06 +0200
commitb4997540dcc7b75441e9b10ee6dcac32cc2708be (patch)
treee543baf0acc77214c44bad9f826d9187459539a9 /mediagoblin/gmg_commands
parente9bb5879f772e4d546aadb4bb6f935c7c55b8000 (diff)
downloadmediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.tar.lz
mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.tar.xz
mediagoblin-b4997540dcc7b75441e9b10ee6dcac32cc2708be.zip
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.
Diffstat (limited to 'mediagoblin/gmg_commands')
-rw-r--r--mediagoblin/gmg_commands/addmedia.py4
-rw-r--r--mediagoblin/gmg_commands/batchaddmedia.py2
-rw-r--r--mediagoblin/gmg_commands/users.py8
3 files changed, 7 insertions, 7 deletions
diff --git a/mediagoblin/gmg_commands/addmedia.py b/mediagoblin/gmg_commands/addmedia.py
index 2c376b76..8cbfc806 100644
--- a/mediagoblin/gmg_commands/addmedia.py
+++ b/mediagoblin/gmg_commands/addmedia.py
@@ -71,13 +71,13 @@ def addmedia(args):
app = commands_util.setup_app(args)
# get the user
- user = app.db.User.query.filter(
+ user = app.db.LocalUser.query.filter(
LocalUser.username==args.username.lower()
).first()
if user is None:
print("Sorry, no user by username '%s'" % args.username)
return
-
+
# check for the file, if it exists...
filename = os.path.split(args.filename)[-1]
abs_filename = os.path.abspath(args.filename)
diff --git a/mediagoblin/gmg_commands/batchaddmedia.py b/mediagoblin/gmg_commands/batchaddmedia.py
index 8012d5e9..ed733b9e 100644
--- a/mediagoblin/gmg_commands/batchaddmedia.py
+++ b/mediagoblin/gmg_commands/batchaddmedia.py
@@ -65,7 +65,7 @@ def batchaddmedia(args):
files_uploaded, files_attempted = 0, 0
# get the user
- user = app.db.User.query.filter(
+ user = app.db.LocalUser.query.filter(
LocalUser.username==args.username.lower()
).first()
if user is None:
diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py
index 0916308d..54c4ec94 100644
--- a/mediagoblin/gmg_commands/users.py
+++ b/mediagoblin/gmg_commands/users.py
@@ -47,7 +47,7 @@ def adduser(args):
db = mg_globals.database
users_with_username = \
- db.User.query.filter(
+ db.LocalUser.query.filter(
LocalUser.username==args.username.lower()
).count()
@@ -88,7 +88,7 @@ def makeadmin(args):
db = mg_globals.database
- user = db.User.query.filter(
+ user = db.LocalUser.query.filter(
LocalUser.username==six.text_type(args.username.lower())
).one()
if user:
@@ -117,7 +117,7 @@ def changepw(args):
db = mg_globals.database
- user = db.User.query.filter(
+ user = db.LocalUser.query.filter(
LocalUser.username==six.text_type(args.username.lower())
).one()
if user:
@@ -141,7 +141,7 @@ def deleteuser(args):
db = mg_globals.database
- user = db.User.query.filter(
+ user = db.LocalUser.query.filter(
LocalUser.username==args.username.lower()
).first()
if user: