def add_handler_lib(self, name, permissionid): """08为视图添加权限函数""" permission = Permission.by_id(permissionid) handler = Handler.by_name(name) if permission is None: return if handler is None: handler = Handler() handler.name =name handler.permission = permission self.db.add(handler) self.db.commit()
def add_handler_lib(self, name, permissionid): """08为视图添加权限函数""" permission = Permission.by_id(permissionid) if permission is None: flash(self, "处理器权限,添加失败", "error") return hanlder = Handler.by_name(name) # 注意 if hanlder is None: hanlder = Handler() hanlder.name = name hanlder.permission = permission self.db.add(hanlder) self.db.commit() flash(self, "处理器权限,添加成功", "success")
def add_handler_lib(self, name, permissionid): permission = Permission.by_id(permissionid) if permission is None: return hanlder = Handler.by_name(name) # 注意 if hanlder is None: hanlder = Handler() hanlder.name = name hanlder.permission = permission # 问题 可不可以 self.db.add(hanlder) self.db.commit()
def add_handler_lib(self, name, permissionid): """08为处理器添加权限""" permission = Permission.by_id(permissionid) handler = Handler.by_name(name) if permission is None: return if handler is None: handler = Handler() handler.name = name handler.permission = permission self.db.add(handler) self.db.commit() flash(self, "处理器权限添加成功", "success")
def del_handler_lib(self, handlerid): """09删除视图函数""" handler = Handler.by_id(handlerid) if handler is None: return self.db.delete(handler) self.db.commit()
def del_handler_lib(self, handlerid): """09删除处理器""" handler = Handler.by_id(handlerid) if handler is None: return self.db.delete(handler) self.db.commit() flash(self, "处理器删除成功", "success")
def permission_manager_list_lib(self): ''' 返回给权限管理页面 ''' roles = Role.all() permissions = Permission.all() menus = Menu.all() handlers = Handler.all() users = User.all() return roles, permissions, menus, handlers, users
def del_handler(self, handlerid): ''' 删除处理器权限 ''' handler = Handler.by_id(handlerid) if handler is None: return {'status': False, 'msg': '该信息不存在'} self.db.delete(handler) self.db.commit() return {'status': True}
def del_handler_lib(self,handlerid): """09删除视图函数""" handler = Handler.by_id(handlerid) if handler is None: flash(self, "处理器权限,删除失败", "error") return self.db.delete(handler) self.db.commit() flash(self, "处理器权限,删除成功", "success")
def permission_manager_list_lib(self): # 获取所有的角色/权限/菜单/处理器/用户 roles = Role.all() permissions = Permission.all() menus = Menu.all() handlers = Handler.all() users = User.all() return roles, permissions, menus, handlers, users
def del_handler_lib(self, handlerid): '''09删除处理器''' handler = Handler.by_id(handlerid) # 判断该c处理器id获取值是否为空 if handler is None: flash(self, '处理器不存在,删除失败!', 'error') return self.db.delete(handler) self.db.commit() flash(self, '处理器删除成功!', 'success')
def add_handler(self, view_name, permission_id): ''' 为处理器添加权限 ''' if view_name == '' or permission_id == '': return {'status': False, 'msg': '请输入视图名和权限名'} permission = Permission.by_id(permission_id) if permission is None: return {'status': False, 'msg': '请输入有效的权限ID'} handler = Handler.by_name(view_name) if handler: handler.p_id = permission_id self.db.add(handler) self.db.commit() return {'status': True} handler = Handler() handler.name = view_name handler.p_id = permission_id self.db.add(handler) self.db.commit() return {'status': True}
def add_handler_lib(self, name, permissionid): '''08添加处理器''' if not name or not permissionid: flash(self, '请输入处理器或权限id!', 'error') permission = Permission.by_id(permissionid) # 判断权限是否存在,不存在直接返回,存在,在验证菜单部分 if permission is None: flash(self, '该权限id不存在!', 'error') return handler = Handler.by_name(name) # 如果权限是空,则创建 if handler is None: handler = Handler() handler.name = name # 问题,这里可不可以添加进去 # 方法1:通过orm的方式添加数据 # handler.permission = permission # 方法2:同过数据库字段的方式添加数据 handler.p_id = permissionid self.db.add(handler) self.db.commit() flash(self, '处理器添加成功!', 'success')
def permission_manager_list_lib(self): """01权限管理页面函数""" roles = Role.all() permissions = Permission.all() menus = Menu.all() handlers = Handler.all() users = User.all() #研发员工 dev_role = Role.by_name('研发员工') dev_users = dev_role.users if dev_role else [] return roles, permissions, menus, handlers, users, dev_users, dev_role.id
def permission_manage_list_lib(self): """01权限管理页面函数""" roles = Role.all() permissions = Permission.all() menus = Menu.all() handlers = Handler.all() users = User.all() # 研发员工 dev_role = Role.by_name('研发部门') dev_users = dev_role.users if dev_role else [] # print("*****") # print(type(dev_role)) # print(dev_role) if dev_role is None: return roles, permissions, menus, handlers, users, dev_users, None return roles, permissions, menus, handlers, users, dev_users, dev_role.id