Beispiel #1
0
def delete_card(id):

	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)
	if not card:
		abort(404)

	query = CardQuery().delete_card(id)
	Database().run_query(query)

	return "Delete successful"
Beispiel #2
0
def create_card():

	data = request.get_json() or {}

	if 'title' not in data or 'list_id' not in data:
		abort(400)

	cid = str(uuid.uuid1())
	data['id'] = cid

	query = CardQuery().add_card(data)
	Database().run_query(query)

	query = CardQuery().get_card_by_id(cid)
	card = Database().run_query(query)

	return jsonify({'cards': card}), 201
Beispiel #3
0
def get_card(id):
	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)

	if not card:
		abort(404)

	return jsonify({'cards': card})
Beispiel #4
0
def update_card(id):

	data = request.get_json() or {}
	if not data:
		abort(400)

	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)

	if not card:
		abort(404)

	query = CardQuery().edit_card(data, id)
	Database().run_query(query)

	query = CardQuery().get_card_by_id(id)
	card = Database().run_query(query)

	return jsonify({'cards': card})
Beispiel #5
0
def get_list(id):
    query = Query().get_list_by_id(id)
    list = Database().run_query(query)

    if not list:
        abort(404)

    query = CardQuery().get_list_cards(id)
    list[0]['cards'] = Database().run_query(query)

    return jsonify({'lists': list})
Beispiel #6
0
def get_board(id):
    query = BoardQuery().get_board_by_id(id)
    board = Database().run_query(query)

    if not board:
        abort(404)

    query = Query().get_board_lists(id)
    lists = Database().run_query(query)
    for l in lists:
        query = CardQuery().get_list_cards(l['id'])
        l['cards'] = Database().run_query(query)

    board[0]['lists'] = lists
    return jsonify({'boards': board})
Beispiel #7
0
def get_cards():
	query = CardQuery().get_all_cards()
	cards = Database().run_query(query)

	return jsonify({'cards': cards})