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"
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
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})
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})
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})
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})
def get_cards(): query = CardQuery().get_all_cards() cards = Database().run_query(query) return jsonify({'cards': cards})