12
12
13
13
@lru_cache ()
14
14
def get_admin_action_options (
15
- group : AdminGroup ,
15
+ group : AdminGroup ,
16
16
) -> List [Dict [str , Any ]]:
17
17
"""获取全部页面权限,用于amis组件"""
18
18
options = []
@@ -28,10 +28,13 @@ def get_admin_action_options(
28
28
if isinstance (admin , BaseActionAdmin ):
29
29
item ["children" ] = []
30
30
if isinstance (admin , ModelAdmin ):
31
- item ["children" ].append ({"label" : "查看列表" , "value" : permission_encode (admin .unique_id , "page:list" , "page" )})
32
- item ["children" ].append ({"label" : "筛选列表" , "value" : permission_encode (admin .unique_id , "page:filter" , "page" )})
31
+ item ["children" ].append (
32
+ {"label" : "View list" , "value" : permission_encode (admin .unique_id , "page:list" , "page" )}) # 查看列表
33
+ item ["children" ].append ({"label" : "Filter list" ,
34
+ "value" : permission_encode (admin .unique_id , "page:filter" , "page" )}) # 筛选列表
33
35
elif isinstance (admin , FormAdmin ) and "submit" not in admin .registered_admin_actions :
34
- item ["children" ].append ({"label" : "提交" , "value" : permission_encode (admin .unique_id , "page:submit" , "page" )})
36
+ item ["children" ].append (
37
+ {"label" : "submit" , "value" : permission_encode (admin .unique_id , "page:submit" , "page" )}) # 提交
35
38
for admin_action in admin .registered_admin_actions .values ():
36
39
# todo admin_action 下可能有多个action,需要遍历
37
40
item ["children" ].append (
@@ -48,7 +51,8 @@ def get_admin_action_options(
48
51
return options
49
52
50
53
51
- def filter_options (options : List [Dict [str , Any ]], filter_func : Callable [[Dict [str , Any ]], bool ]) -> List [Dict [str , Any ]]:
54
+ def filter_options (options : List [Dict [str , Any ]], filter_func : Callable [[Dict [str , Any ]], bool ]) -> List [
55
+ Dict [str , Any ]]:
52
56
"""过滤选项,包含子选项.如果选项的children为空,则删除该选项"""
53
57
result = []
54
58
for option in options :
@@ -64,9 +68,9 @@ def filter_options(options: List[Dict[str, Any]], filter_func: Callable[[Dict[st
64
68
65
69
66
70
def get_admin_action_options_by_subject (
67
- enforcer : AsyncEnforcer ,
68
- subject : str ,
69
- group : AdminGroup ,
71
+ enforcer : AsyncEnforcer ,
72
+ subject : str ,
73
+ group : AdminGroup ,
70
74
):
71
75
"""获取指定subject主体的页面权限,用于amis组件"""
72
76
# 获取全部页面权限
0 commit comments