aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/gmg_commands/users.py
diff options
context:
space:
mode:
authorLoïc Le Ninan <loic.leninan@gmail.com>2014-06-07 23:45:50 +0200
committerChristopher Allan Webber <cwebber@dustycloud.org>2014-06-11 16:42:26 -0500
commit8c7ba963afbe6b643e28308466adc8cc42208416 (patch)
treec7e6c2bee16cd0d7063ce04cba078072f98042d9 /mediagoblin/gmg_commands/users.py
parent8db3277cd7dafd07a0625a6a7b104e7ceea889d5 (diff)
downloadmediagoblin-8c7ba963afbe6b643e28308466adc8cc42208416.tar.lz
mediagoblin-8c7ba963afbe6b643e28308466adc8cc42208416.tar.xz
mediagoblin-8c7ba963afbe6b643e28308466adc8cc42208416.zip
#303 : enhancement : add a command to delete users
Diffstat (limited to 'mediagoblin/gmg_commands/users.py')
-rw-r--r--mediagoblin/gmg_commands/users.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/mediagoblin/gmg_commands/users.py b/mediagoblin/gmg_commands/users.py
index 4a730d9e..186557e0 100644
--- a/mediagoblin/gmg_commands/users.py
+++ b/mediagoblin/gmg_commands/users.py
@@ -115,3 +115,23 @@ def changepw(args):
print 'Password successfully changed'
else:
print 'The user doesn\'t exist'
+
+
+def deleteuser_parser_setup(subparser):
+ subparser.add_argument(
+ 'username',
+ help="Username to delete")
+
+
+def deleteuser(args):
+ commands_util.setup_app(args)
+
+ db = mg_globals.database
+
+ user = db.User.query.filter_by(
+ username=unicode(args.username.lower())).one()
+ if user:
+ user.delete()
+ print 'The user %s has been deleted' % args.username
+ else:
+ print 'The user %s doesn\'t exist' % args.username