def remove_manager(self, db_session: Session, manager_id): manager = db_session.query(Manager).get(manager_id) if manager is None: raise NoResultFound("Manager not found") db_session.delete(manager) db_session.commit() return manager
def remove_time_table(self, db_session: Session, time_table_id: int): time_table = db_session.query(TimeTable).get(time_table_id) if time_table_id is None: raise NoResultFound('Time Table not found') db_session.delete(time_table) db_session.commit() return time_table
def remove(self, db_session: Session, community_id: int, user_id: int): community = (db_session.query(Community).options( lazyload("admins")).get(community_id)) if community is None: raise NoResultFound("Community not found") user = db_session.query(User).get(user_id) if user is None: raise NoResultFound("User not found") if user not in community.admins: raise Exception("User is not admin of this community") db_session.delete(community) db_session.commit() return community