def patch_connection(connection_id): conn_type = request.args.get('connection_type') connection = Connection.query.get(connection_id) connection.connection_type = conn_type connection.update(connection) connection_schema = ConnectionSchema() return connection_schema.jsonify(connection), HTTPStatus.OK
def update_connection_type(args, connection_id): connection_schema = ConnectionSchema() new_connection_type = args['connection_type'] connection = Connection.query.get_or_404( connection_id) # If not found, return 404 # Validate Connection Type if new_connection_type not in ConnectionType.list(): return 'Invalid Connection Type', HTTPStatus.BAD_REQUEST # Set value and save connection.connection_type = ConnectionType[new_connection_type] connection.save() return connection_schema.jsonify(connection), HTTPStatus.OK
def get_connections(): connection_schema = ConnectionSchema(many=True) connections = Connection.query.all() return connection_schema.jsonify(connections), HTTPStatus.OK
def get_connection(): connection_schema = ConnectionSchema(many=True) connection = Connection.query.join( Person, Person.id == Connection.from_person_id).all() pprint.pprint(connection[0]) return connection_schema.jsonify(connection), HTTPStatus.OK
def delete_connection(connection_id): connection = Connection.query.get(connection_id) connection.delete(connection) connection_schema = ConnectionSchema() return connection_schema.jsonify(connection), HTTPStatus.OK
def get_connection(connection_id): connection_schema = ConnectionSchema() connection = Connection.query.get(connection_id) return connection_schema.jsonify(connection), HTTPStatus.OK