def add_new_status_to_board(board_id: int, new_status_name: str): if new_status_name in persistence.get_statuses_list(): status_id = persistence.get_status_id_by_status_name(new_status_name) persistence.get_status_board_connections().append({ 'board_id': board_id, 'status_id': status_id, 'order': persistence.new_order_number_to_board_status_connections( board_id, status_id) }) persistence.export_data('board_statuses') else: new_id = persistence.new_id_to_csv(persistence.STATUSES_FILE) new_status = {'id': new_id, 'title': new_status_name} persistence.get_statuses_dict().append(new_status) persistence.export_data('statuses') persistence.get_status_board_connections().append({ 'board_id': board_id, 'status_id': new_id, 'order': persistence.new_order_number_to_board_status_connections( board_id, status_id) }) persistence.export_data('board_statuses')
def register_user(username, password): new_user = { "id": persistence.new_id_to_csv(persistence.USERS_FILE), "username": username, "password": hash_password(password) } persistence.get_users().append(new_user) persistence.export_data("users")
def add_card_to_board(board_id, card_title): new_card = { "id": persistence.new_id_to_csv(persistence.CARDS_FILE), "board_id": board_id, "title": card_title, "status_id": "0", "order": persistence.new_order_number_to_cards(board_id, 0), "archived": "0" } persistence.get_cards().append(new_card) persistence.export_data("cards")
def add_board(board_name, creator_username="******", private=0): new_board = { "id": persistence.new_id_to_csv(persistence.BOARDS_FILE), "title": board_name, "creator": creator_username, "private": private } persistence.get_boards().append(new_board) persistence.export_data("boards") # add starter statuses to new boards starter_statuses = [{ 'board_id': new_board['id'], 'status_id': i, 'order': persistence.new_order_number_to_board_status_connections( new_board['id'], i) } for i in range(0, 4)] board_status_connections = persistence.get_status_board_connections() for connection in starter_statuses: board_status_connections.append(connection) persistence.export_data('board_statuses')
def rename_status(board_id, status_id, new_status): new_status_id = persistence.get_status_id_by_status_name(new_status) if new_status_id: pass else: new_status_id = persistence.new_id_to_csv(persistence.STATUSES_FILE) new_status = {'id': new_status_id, 'title': new_status} persistence.get_statuses_dict().append(new_status) persistence.export_data('statuses') cards = persistence.get_cards() for card in cards: if int(card['status_id']) == status_id and int( card['board_id']) == board_id: card['status_id'] = new_status_id persistence.export_data('cards') connections = persistence.get_status_board_connections() for connection in connections: if int(connection['board_id']) == board_id and int( connection['status_id']) == status_id: connection['status_id'] = new_status_id break persistence.export_data('board_statuses')