Modify deleteuser to fail gracefully
authorayleph <ayleph@thisshitistemp.com>
Tue, 16 Sep 2014 22:29:09 +0000 (15:29 -0700)
committerayleph <ayleph@thisshitistemp.com>
Tue, 16 Sep 2014 22:29:09 +0000 (15:29 -0700)
bin/gmg deleteuser will produce a traceback error if you attempt to delete a
user who does not exist. This commit provides a fix to allow deletuser to fail
gracefully.

This commit addresses https://issues.mediagoblin.org/ticket/969

mediagoblin/gmg_commands/users.py

index 71149497b2aa81f18a444185f2bfc2c739a4ed5a..d34f50e2d395007bf621eddcfdf6c607522dd558 100644 (file)
@@ -129,7 +129,7 @@ def deleteuser(args):
     db = mg_globals.database
 
     user = db.User.query.filter_by(
-        username=unicode(args.username.lower())).one()
+        username=unicode(args.username.lower())).first()
     if user:
         user.delete()
         print 'The user %s has been deleted' % args.username