Deploy AIOS web (React glide grid + FastAPI slice)
Browse files- api/routes_admin.py +18 -5
api/routes_admin.py
CHANGED
|
@@ -330,9 +330,13 @@ def set_password(username: str, body: dict = Body(default=None),
|
|
| 330 |
|
| 331 |
# ββ C-PERM (wave 15): per-module access + permanent filters + hidden fields ββββββββββββββββββ
|
| 332 |
#: The modules the permission editor governs β the GRID surfaces, the ones with a field schema
|
| 333 |
-
#: to filter and hide. Amendment 6
|
| 334 |
-
#:
|
| 335 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 336 |
|
| 337 |
|
| 338 |
def _module_fields(key):
|
|
@@ -343,15 +347,24 @@ def _module_fields(key):
|
|
| 343 |
what to hide, so hiding the choices would make a field unhideable the moment it was hidden
|
| 344 |
once for somebody. The route is admin-gated; the projection a MEMBER receives is the one
|
| 345 |
`perm_scope.visible_fields` narrows.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 346 |
"""
|
| 347 |
import aios_grid
|
|
|
|
| 348 |
out = []
|
| 349 |
-
for f in
|
| 350 |
if not isinstance(f, dict) or not f.get("key"):
|
| 351 |
continue
|
| 352 |
out.append({"key": f["key"], "label": f.get("label") or f["key"],
|
| 353 |
"type": f.get("type") or "text",
|
| 354 |
-
**({"options": f["options"]} if isinstance(f.get("options"), list) else {})
|
|
|
|
| 355 |
return out
|
| 356 |
|
| 357 |
|
|
|
|
| 330 |
|
| 331 |
# ββ C-PERM (wave 15): per-module access + permanent filters + hidden fields ββββββββββββββββββ
|
| 332 |
#: The modules the permission editor governs β the GRID surfaces, the ones with a field schema
|
| 333 |
+
#: to filter and hide. Amendment 6 shipped the wall on `customer_data` alone and said this list
|
| 334 |
+
#: is the one place that changes when C-TOPIC lands. WAVE 16: it landed, so `product_data`
|
| 335 |
+
#: joins β and it is not cosmetic. `perms_v: 1` means an UNDECLARED module DENIES (amendment 4),
|
| 336 |
+
#: so a migrated account would be locked out of Product with no control anywhere to grant it:
|
| 337 |
+
#: fail-closed, but unadministrable. The editor grows its section with zero client edits
|
| 338 |
+
#: (S3 built it off this route's `modules` + `fields_by_module`).
|
| 339 |
+
_PERM_MODULES = ("customer_data", "product_data")
|
| 340 |
|
| 341 |
|
| 342 |
def _module_fields(key):
|
|
|
|
| 347 |
what to hide, so hiding the choices would make a field unhideable the moment it was hidden
|
| 348 |
once for somebody. The route is admin-gated; the projection a MEMBER receives is the one
|
| 349 |
`perm_scope.visible_fields` narrows.
|
| 350 |
+
|
| 351 |
+
β PER TOPIC (wave 16). `product_data` has its OWN canonical contract, and handing the
|
| 352 |
+
editor the customer schema for it would let an admin build a wall out of columns that
|
| 353 |
+
module does not have β `_clean_perms` would then 400 on the admin's own choices, or worse,
|
| 354 |
+
a filter naming a field the product rows lack would DENY every row via `permits()`.
|
| 355 |
+
The product contract is served CONSOLIDATED (every column) on purpose: a BU-scoped reader
|
| 356 |
+
is served fewer columns, but the ADMIN is choosing what may ever be hidden.
|
| 357 |
"""
|
| 358 |
import aios_grid
|
| 359 |
+
src = aios_grid.product_fields() if key == "product_data" else aios_grid.FIELDS
|
| 360 |
out = []
|
| 361 |
+
for f in src:
|
| 362 |
if not isinstance(f, dict) or not f.get("key"):
|
| 363 |
continue
|
| 364 |
out.append({"key": f["key"], "label": f.get("label") or f["key"],
|
| 365 |
"type": f.get("type") or "text",
|
| 366 |
+
**({"options": f["options"]} if isinstance(f.get("options"), list) else {}),
|
| 367 |
+
**({"pinned": True} if f.get("pinned") else {})})
|
| 368 |
return out
|
| 369 |
|
| 370 |
|