def add_role_lib(self, name): """02添加角色函数""" role= Role.by_name(name) if role is not None: flash(self, "角色已经存在,添加失败", "error") return role = Role() role.name = name self.db.add(role) 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 save_role_name(self, role_name): ''' 存入新增角色名 ''' if role_name == '': flash(self, "角色不能为空", "error") return role = Role.by_name(role_name) if role is not None: flash(self, "角色已经存在", "error") return role = Role() role.name = role_name self.db.add(role) self.db.commit() flash(self, "角色添加成功", "success")
def add_role_lib(self, name): '''02添加一个角色''' if not name: flash(self, '请输入角色名称!', 'error') return print type(name), 'name:%s' % name role = Role.by_name(name) if role is not None: flash(self, '角色已经存在!', 'error') return role = Role() role.name = name self.db.add(role) self.db.commit() flash(self, '角色添加成功!', 'success')
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