def delete_label(id): # 删除场景 try: com_del(db, Label, id=id) except Exception as e: current_app.logger.error("[label][del] fail expection: {}".format(e)) return InvalidMessage(str(e), 500) return return_data('delete success', 204)
def delete_head(id): try: head = com_get(Head, id=id) except Exception as e: current_app.logger.error("[head][get] fail expection: {}".format(e)) return InvalidMessage(str(e), 500) head.groups = [] # 删除场景 try: com_del(db, Head, id=id) except Exception as e: current_app.logger.error("[head][del] fail expection: {}".format(e)) return InvalidMessage(str(e), 500) return return_data('delete success', 204)
def delete_subject(id): try: subject = com_get(Subject, id=id) except Exception as e: current_app.logger.error("[subject][get] fail expection: {}".format(e)) return InvalidMessage(str(e), 500) # 清除外键多对多数据关联 subject.labels = [] # 删除试题 try: com_del(db, Subject, id=id) except Exception as e: current_app.logger.error("[subject][del] fail expection: {}".format(e)) return InvalidMessage(str(e), 500) return return_data('delete success', 204)
def delete_group(id): # 获取组对象 try: group = com_get(Group, id=id) except Exception as e: current_app.logger.error("[group][get] fail expection: {}".format(e)) raise InvalidMessage(str(e), 500) # 从组中移除所有用户 try: user_helper.remove_all_user_to_group(group) except Exception as e: current_app.logger.error( "[group][remove_all_user] fail expection: {}".format(e)) raise InvalidMessage(str(e), 500) # 删除组 try: com_del(db, Group, id=id) except Exception as e: current_app.logger.error("[group][del] fail expection: {}".format(e)) raise InvalidMessage(str(e), 500) return return_data('delete success', 204)