def create_wall(): data = request.get_json() or {} if 'width' not in data or 'height' not in data or 'grade' not in data: return bad_request('must include width, height and grade') wall = Wall() data['active'] = False wall.from_dict(data) db.session.add(wall) db.session.commit() response = jsonify(wall.to_dict()) response.status_code = 201 response.headers['Location'] = url_for('api.get_wall', wallid=wall.id) return response
def add_new_wall(data): uuid = data.get('uuid') name = data.get('name') texture_id = data.get('texture_id') room_id = data.get('room_id') x_pos = data.get('x_pos') y_pos = data.get('y_pos') z_pos = data.get('z_pos') user_id = get_user_id(uuid=uuid) if user_id: wall = Wall(room_id=room_id, texture_id=texture_id, name=name, x_pos=x_pos, y_pos=y_pos, z_pos=z_pos) wall.save() return generate_wall_created_success_response(wall) else: return generate_user_not_login_response()