Add ability to delete users

This commit is contained in:
Jonathan Wong 2015-11-27 21:13:17 -08:00
parent c501923f2b
commit 1c00f82097
7 changed files with 160 additions and 21 deletions

View file

@ -1397,6 +1397,40 @@ class WebInterface(object):
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': 'no data received'})
@cherrypy.expose
def delete_user(self, user_id, **kwargs):
data_factory = datafactory.DataFactory()
if user_id:
delete_row = data_factory.delete_user(user_id=user_id)
if delete_row:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': delete_row})
else:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': 'no data received'})
@cherrypy.expose
def undelete_user(self, user_id=None, username=None, **kwargs):
data_factory = datafactory.DataFactory()
if user_id:
delete_row = data_factory.undelete_user(user_id=user_id)
if delete_row:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': delete_row})
elif username:
delete_row = data_factory.undelete_user(username=username)
if delete_row:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': delete_row})
else:
cherrypy.response.headers['Content-type'] = 'application/json'
return json.dumps({'message': 'no data received'})
@cherrypy.expose
def search(self, query=''):