fix: register /{module}/{table} page path for CRUD table menu items in init_permissions.py
- Menu items use url='{{entire_url('/module/table')}}' format
- init_permissions.py now registers both the page path and CRUD API endpoints
- Page path: /{module}/{table} (for menu navigation)
- API paths: /{module}/api/{table}_{list|create|update|delete}.dspy
This commit is contained in:
parent
cbbc179491
commit
98e1bbe96a
@ -291,20 +291,30 @@ async def main():
|
||||
|
||||
print(f" 注册权限: {perm_count}, 授权次数: {grant_count}, 错误: {error_count}")
|
||||
|
||||
# ---- 4c: 注册 CRUD API 权限 ----
|
||||
print(f"\n [4c] 注册 CRUD API 权限...")
|
||||
# ---- 4c: 注册 CRUD API 权限 + 数据表页面权限 ----
|
||||
print(f"\n [4c] 注册 CRUD API 和数据表页面权限...")
|
||||
crud_count = 0
|
||||
for module, tables in pc.CRUD_TABLES.items():
|
||||
for table in tables:
|
||||
# 1) 注册数据表页面路径: /{module}/{table} (menu.ui 中菜单项的 url)
|
||||
page_path = f"/{module}/{table}"
|
||||
try:
|
||||
permid = await ensure_permission(sor, page_path, permtype='page')
|
||||
await grant_perm(sor, role_ids['admin_superuser'], permid)
|
||||
crud_count += 1
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# 2) 注册 CRUD API 端点: list/create/update/delete
|
||||
for action in ('list', 'create', 'update', 'delete'):
|
||||
path = f"/{module}/api/{table}_{action}.dspy"
|
||||
api_path = f"/{module}/api/{table}_{action}.dspy"
|
||||
try:
|
||||
permid = await ensure_permission(sor, path, permtype='api')
|
||||
permid = await ensure_permission(sor, api_path, permtype='api')
|
||||
await grant_perm(sor, role_ids['admin_superuser'], permid)
|
||||
crud_count += 1
|
||||
except Exception:
|
||||
pass
|
||||
print(f" 注册 CRUD API: {crud_count}")
|
||||
print(f" 注册 CRUD 权限: {crud_count}")
|
||||
|
||||
# ---- 4d: 同步 admin_superuser 权限到各机构角色 ----
|
||||
print(f"\n [4d] 同步 admin_superuser 权限到各机构已有角色...")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user