def update_apps(): user_app = UserApp() try: user_id = current_user.get_id() apps_json_str = request.form["apps"] apps_json = json.loads(apps_json_str) result = user_app.set(user_id, apps_json ) except Exception as e: print e raise ExceptionResponse("Bad json", 400) try: if result: response = {} response['data'] = result return jsonify(response) else: return "lol no data" except psycopg2.DatabaseError as e: print e raise ExceptionResponse() except Exception as e: print e raise ExceptionResponse()
def get_apps(): user_app = UserApp() try: user_id = current_user.get_id() apps = user_app.get(user_id) if apps: response = {} response['user'] = current_user.serialize() response['apps'] = apps return jsonify(response) except Exception as e: print e raise ExceptionResponse()
def test_get_apps(): app_mapper = UserApp() apps = app_mapper.get(1) print apps
def test_update_apps(): app_mapper = UserApp() res = app_mapper.set(1, '{"attr":"loler"}') print res