def add_activity(activity): if not isinstance(activity, Activity): return status_code = 201 session = Session() try: session.add(activity) except: session.rollback() status_code = 409 finally: session.commit() id = activity.id session.close() return status_code, id
def add_card(card): if not isinstance(card, Card): return status_code = 201 session = Session() try: session.add(card) except: session.rollback() status_code = 409 finally: session.commit() id = card.id session.close() return status_code, id
def add_list(li): if not isinstance(li, List): return status_code = 201 session = Session() try: session.add(li) except: session.rollback() status_code = 409 finally: session.commit() id = li.id session.close() return status_code, id
def add_user(user): if not isinstance(user, User): return None status_code = 201 session = Session() try: session.add(user) except: session.rollback() status_code = 409 finally: session.commit() id = user.id session.close() return status_code, id
def update_list(li): if not isinstance(li, List) or li.id is None: return status_code = 200 session = Session() try: old_list = session.query(List).filter_by(id=li.id).first() old_list.name = li.name except: session.rollback() status_code = 409 finally: session.commit() id = li.id session.close() return status_code, id
def find_boards_by_username(username): session = Session() user = find_user_by_username(username) if user is not None: result = session.query(Board).filter_by(user_id=user.id, active=1).all() session.close() return result session.close() return None
def update_board(board): if not isinstance(board, Board) or board.id is None: return status_code = 200 session = Session() try: old_card = session.query(Board).filter_by(id=board.id).first() old_card.name = board.name old_card.bg_color = board.bg_color old_card.active = board.active except: session.rollback() status_code = 409 finally: session.commit() id = board.id session.close() return status_code, id
def update_card(card): if not isinstance(card, Card) or card.id is None: return status_code = 200 session = Session() try: old_card = session.query(Card).filter_by(id=card.id).first() old_card.name = card.name old_card.description = card.description old_card.date_to = card.date_to except: session.rollback() status_code = 409 finally: session.commit() id = card.id session.close() return status_code, id
def find_lists_by_board_id(board_id): session = Session() result = session.query(List).filter_by(board_id=board_id) return result
def find_user_by_username(username): session = Session() user = session.query(User).filter_by(username=username).first() session.close() return user
def find_user_by_id(id): session = Session() user = session.query(User).filter_by(id=id).first() session.close() return user
def find_user_by_email(email): session = Session() user = session.query(User).filter_by(email=email).first() session.close() return user
def find_board_by_board_id(id): session = Session() result = session.query(Board).filter_by(id=id, active=1).first() session.close() return result
def find_boards_by_user_id(user_id): session = Session() result = session.query(Board).filter_by(user_id=user_id, active=1).all() session.close() return result