Example #1
0
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")