示例#1
0
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
示例#2
0
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
示例#3
0
def get_connections():
    connection_schema = ConnectionSchema(many=True)
    connections = Connection.query.all()

    return connection_schema.jsonify(connections), HTTPStatus.OK
示例#4
0
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
示例#5
0
def delete_connection(connection_id):
    connection = Connection.query.get(connection_id)
    connection.delete(connection)
    connection_schema = ConnectionSchema()
    return connection_schema.jsonify(connection), HTTPStatus.OK
示例#6
0
def get_connection(connection_id):
    connection_schema = ConnectionSchema()
    connection = Connection.query.get(connection_id)
    return connection_schema.jsonify(connection), HTTPStatus.OK