def card_delete(card_id): card = data_manager.get_card_by_id(card_id) board = data_manager.get_board_by_id(card['board_id']) if board['user_id'] == session.get('user_id') or board['user_id'] == -1: data_manager.delete_card(card_id) return json.dumps(True) return json.dumps(False)
def cards_by_board_id(board_id): board = data_manager.get_board_by_id(board_id) if board: if board.get('user_id') == session.get('user_id') or board.get( 'user_id') == -1: return json.dumps(data_manager.get_cards_by_board_id(board_id)) return json.dumps(False)
def cards_by_id(card_id): card = data_manager.get_card_by_id(card_id) if card: board = data_manager.get_board_by_id(card.get("board_id")) if board.get("user_id") == session.get("user_id", -1): return json.dumps(data_manager.get_card_by_id(card_id)) return json.dumps(False)
def archive_card(card_id): card = data_manager.get_card_by_id(card_id) board = data_manager.get_board_by_id(card.get('board_id')) if not board.get('user_id'): return json.dumps({'error': 'card not found'}) if board.get('user_id') == session.get("user_id") or board.get( 'user_id') == -1: return json.dumps(data_manager.toggle_archived_state_for_card(card_id)) return json.dumps({'error': 'invalid user'})
def board_rename(): board = data_manager.get_board_by_id(request.form['board_id']) if session['user_id'] == board['user_id'] or board['user_id'] == -1: if security.check_text_validity(request.form['new_title'], extra_characters=" '"): return json.dumps( data_manager.rename_board(request.form['board_id'], request.form['new_title'])) return json.dumps(False) return json.dumps(False)
def statuses_for_board(board_id): user_id = data_manager.get_board_by_id(board_id).get("user_id") if user_id == session.get("user_id") or user_id == -1: return json.dumps(data_manager.get_statuses_for_board(board_id)) return json.dumps(False)
def board_by_id(board_id): board = data_manager.get_board_by_id(board_id) if board["user_id"] == session["user_id"]: return json.dumps(board) return json.dumps(False)
def get_card_archive(board_id): board = data_manager.get_board_by_id(board_id) if board.get('user_id') == session.get('user_id') or board.get( 'user_id') == -1: return json.dumps(data_manager.get_archived_cards_for_board(board_id)) return json.dumps({'error': 'invalid user'})