def removeUser(): user_id = bottle.request.forms.get('id') if HomerHelper.idCheck('Users', user_id): #validate the device ID user_name = HomerHelper.getUserName(user_id) try: db.query("DELETE FROM Users WHERE id = %s", user_id) #con.commit() HomerHelper.insert_history(user_name, user_id, "user removed") return("OK") except MySQLdb.IntegrityError: bottle.abort(400, "Doh! Unable to remove device. ") else: err_msg = "Doh! That request was no bueno. %s is not a valid ID or it is not enrolled in HOMEr" % user_id bottle.abort(400, err_msg)
def setLocation(): user_id = bottle.request.params.get('id') user_location = bottle.request.params.get('location') if HomerHelper.userIdCheck(user_id): user_name = HomerHelper.getUserName(user_id) try: sql_update = "UPDATE `Users` SET `Location`= %s WHERE ID = %s" db.query(sql_update, (user_location, user_id)) history_event = "set user location to: " + user_location HomerHelper.insert_history(user_name, user_id, history_event) return "OK" except MySQLdb.IntegrityError: bottle.abort(400, "Doh! User doesn't exist") else: bottle.abort(400, "Doh! User ID was not found")