def wrapper(*args, **kwargs): valid = True err_str = None try: data = schema.loads(request.data) except ValidationError as err: valid = False print({ "message": "error validating schema", "request body": json.loads(request.data), "function": func.__name__ }) except Exception as err: valid = False err_str = str(err) print({ "message": "could not parse request body", "request body": request.data, "function": func.__name__ }) if valid is False: err_msg = "could not parse request body" if err_str: err_msg = err_msg + ": " + err_str return jsonify( create_error_response( ErrorCodes.VALIDATE_INPUT_SCHEMA_FAILED, err_msg)) return func(data, *args, **kwargs)
def generate_pic_size_not_found_response(pic_size_id): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_PIC_SIZE_NOT_FOUND, 'Pic Size not found: ' + pic_size_id))
def generate_user_not_authorised_response(): return json.dumps( create_error_response(ErrorCodes.ERROR_CODE_USER_NOT_AUTHORIZED, 'User not authorized for this action'))
def generate_default_value_not_found_response(): return json.dumps( create_error_response(ErrorCodes.ERROR_CODE_DEFAULT_TEXTURE_NOT_FOUND, 'default texture not found'))
def generate_painting_contains_real_sizes_response(painting_id): return jsonify(create_error_response(ErrorCodes.ERROR_CODE_PAINTING_CONTAINS_REAL_SIZES, 'Painting ' + painting_id + ' contains \ Real Sizes and cant be removed'))
def generate_wall_not_found_response(wall_id): return json.dumps(create_error_response(ErrorCodes.ERROR_CODE_WALL_NOT_FOUND, 'Wall not found: ' + wall_id))
def generate_global_settings_not_found_response_id(s_id): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_GLOBAL_SETTINGS_NOT_FOUND, 'global settings not found : ' + s_id))
def generate_floor_not_found_response(id): return json.dumps( create_error_response(ErrorCodes.ERROR_CODE_FLOOR_NOT_FOUND, 'Floor not found: ' + str(id)))
def generate_registration_failed_response(exe): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_REGISTRATION_FAILED, 'User registration failed ' + str(exe)))
def generate_floor_name_already_exist_response(name): return json.dumps( create_error_response(ErrorCodes.ERROR_CODE_FLOOR_ALREADY_EXIST, 'Floor ' + name + ' already exist'))
def generate_username_taken_response(username): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_USERNAME_ALREADY_TAKEN, 'Username already taken: ' + username))
def generate_login_failed_response(): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_LOGIN_FAILED, 'Username and Password not found'))
def generate_painting_contains_bg_lights_response(painting_id): return jsonify(create_error_response(ErrorCodes.ERROR_CODE_PAINTING_CONTAINS_BG_LIGHTS, 'Painting ' + painting_id + ' contains \ Bg Lights and cant be removed'))
def generate_texture_not_found_response(texture_id): return json.dumps( create_error_response(ErrorCodes.ERROR_CODE_TEXTURE_NOT_FOUND, 'texture not found: ' + str(texture_id.item_id)))
def generate_room_name_already_exist_response(name): return json.dumps( create_error_response(ErrorCodes.ERROR_CODE_ROOM_ALREADY_EXIST, 'Room ' + name + ' already exist'))
def generate_real_size_not_found_response(real_size_id): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_REAL_SIZE_NOT_FOUND, 'Real Size not found: ' + real_size_id))
def generate_room_not_found_response(room_id): return json.dumps(create_error_response(ErrorCodes.ERROR_CODE_ROOM_NOT_FOUND, 'Room not found: ' + str(room_id)))
def generate_global_settings_not_found_response(): msg = create_error_response(ErrorCodes.ERROR_CODE_GLOBAL_SETTINGS_NOT_FOUND, 'global settings not found') return jsonify(msg)
def generate_room_contains_walls_response(room_id): return json.dumps(create_error_response(ErrorCodes.ERROR_CODE_ROOM_CONTAINS_WALLS, 'Room ' + str(room_id) + ' contains \ walls and cant be removed'))
def generate_user_not_login_response(): return json.dumps(create_error_response(ErrorCodes.ERROR_CODE_USER_NOT_LOGGED_IN, 'User not logged in'))
def generate_bg_light_not_found_response(bg_light_id): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_BG_LIGHT_NOT_FOUND, 'Bg Light not found: ' + bg_light_id))
def generate_wall_contains_paintings_response(wall_id): return json.dumps(create_error_response(ErrorCodes.ERROR_CODE_WALL_CONTAINS_PAINTINGS, 'Wall ' + wall_id + ' contains \ paintings and cant be removed'))
def generate_painting_not_found_response(painting_id): return jsonify( create_error_response(ErrorCodes.ERROR_CODE_PAINTING_NOT_FOUND, 'Painting not found: ' + painting_id))