'setup': 'mediagoblin.gmg_commands.users:changepw_parser_setup',
'func': 'mediagoblin.gmg_commands.users:changepw',
'help': 'Changes a user\'s password'},
+ 'deleteuser': {
+ 'setup': 'mediagoblin.gmg_commands.users:deleteuser_parser_setup',
+ 'func': 'mediagoblin.gmg_commands.users:deleteuser',
+ 'help': 'Deletes a user'},
'dbupdate': {
'setup': 'mediagoblin.gmg_commands.dbupdate:dbupdate_parse_setup',
'func': 'mediagoblin.gmg_commands.dbupdate:dbupdate',
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