66 lines
1.8 KiB
Python
66 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
||
"""RBAC path registration for pipeline-bidding module.
|
||
|
||
与平台惯例一致:静态资源 → any(免登录),页面/CRUD/API → logined。
|
||
由宿主应用根目录执行:py3/bin/python pkgs/pipeline-bidding/scripts/load_path.py
|
||
"""
|
||
import subprocess
|
||
import sys
|
||
|
||
MOD = "pipeline-bidding"
|
||
|
||
TABLES = [
|
||
"bid_mail_accounts", "bid_tenders", "bid_members", "bid_tender_files",
|
||
"bid_scoring_items", "bid_qualifications", "bid_doc_requirements",
|
||
"bid_chapters", "bid_reviews", "bid_scores", "bid_kb_docs", "bid_documents",
|
||
]
|
||
|
||
PATHS_ANY = [
|
||
"/imgs/node-expand.svg",
|
||
"/imgs/node-collapse.svg",
|
||
"/imgs/open-folder.svg",
|
||
"/imgs/close-folder.svg",
|
||
]
|
||
|
||
PATHS_LOGINED = [
|
||
"/%s" % MOD,
|
||
"/%s/index.ui" % MOD,
|
||
]
|
||
for t in TABLES:
|
||
PATHS_LOGINED += [
|
||
"/%s/%s/index.ui" % (MOD, t),
|
||
"/%s/%s/get_%s.dspy" % (MOD, t, t),
|
||
"/%s/%s/add_%s.dspy" % (MOD, t, t),
|
||
"/%s/%s/update_%s.dspy" % (MOD, t, t),
|
||
"/%s/%s/delete_%s.dspy" % (MOD, t, t),
|
||
]
|
||
# 产线业务 API
|
||
PATHS_LOGINED += [
|
||
"/%s/api/" % MOD,
|
||
"/%s/api/bid_probe.dspy" % MOD,
|
||
]
|
||
|
||
|
||
def _run(role, path):
|
||
r = subprocess.run([sys.executable, "set_role_perm.py", role, path],
|
||
capture_output=True, text=True)
|
||
if r.returncode != 0:
|
||
print(" FAIL [%s] %s: %s" % (role, path, (r.stderr or "").strip()[:120]))
|
||
return r.returncode == 0
|
||
|
||
|
||
def main():
|
||
print("=== %s RBAC registration ===" % MOD)
|
||
n = 0
|
||
for p in PATHS_ANY:
|
||
n += _run("any", p)
|
||
print(" any: %s" % p)
|
||
for p in PATHS_LOGINED:
|
||
n += _run("logined", p)
|
||
print(" logined: %s" % p)
|
||
print("Done. %d/%d paths registered" % (n, len(PATHS_ANY) + len(PATHS_LOGINED)))
|
||
|
||
|
||
if __name__ == "__main__":
|
||
main()
|