def get_cards_for_board(board_id: int, status_id: int): """ All cards that belongs to a board :param status_id: id of the statuses board :param board_id: id of the parent board """ return data_handler.get_cards(board_id, status_id)
def rename_card_save(): cards = data_handler.get_cards() data = request.get_json() card_title = data["titles"].split(",") for i in range(len(cards)): cards[i]["title"] = card_title[i] data_handler.save_dict_to_cards_csv(cards)
def del_card(): cards = data_handler.get_cards() data = request.get_json() for i in range(len(cards)): if cards[i]["id"] == data["id"]: del cards[i] data_handler.save_dict_to_cards_csv(cards) return make_response(jsonify({"message": "JSON received"}), 200)
def save_card_position(): cards = data_handler.get_cards() statuses = data_handler.get_statuses() data = request.get_json() for status in statuses: if status['title'] == data['status']: status_id = status['id'] for card in cards: if card['id'] == data['cardId']: card['board_id'] = data['boardId'] card['status_id'] = status_id card['order'] = data['position'] data_handler.save_dict_to_cards_csv(cards) return make_response(jsonify({"message": "JSON received"}), 200)
def add_new_card(): cards = data_handler.get_cards() max_id = 0 for card in cards: if int(card['id']) > max_id: max_id = int(card['id']) data = request.get_json() new_card = { 'id': max_id + 1, 'board_id': data['boardId'], 'title': data['cardName'], 'status_id': 0, 'order': data['position'] } cards.append(new_card) data_handler.save_dict_to_cards_csv(cards) return make_response((jsonify({'message': "JSON received"})), 200)
def show_cards(): if request.method == "GET": return data_handler.get_cards()
def get_cards(): """ All the boards """ return data_handler.get_cards()
def delete_card(card_id: int): data_handler.delete_card(card_id) return data_handler.get_cards()
def create_new_card(board_id: int, status_id: int): data_handler.create_new_card(board_id, status_id) return data_handler.get_cards(board_id, status_id)
def get_cards(): """ Return cards with all the card details """ return data_handler.get_cards()