feat(waiter): what a waiter may do comes from permission keys (platform-v2 step 4.3)
- Payments: ordering.orders.close checked on pay/close and the counter POS
(waiters have it by default, owner decision); pay-offline always recorded.
- The venue switches waiter_cancellations / price_adjust / revert are gone:
ordering.orders.cancel, ordering.prices.modify and the new
ordering.payments.revert (overridable) decide; moves/split/transfer/merge
need ordering.orders.open; discounts pricing.discounts.apply; chat chat.use.
- Venue role defaults: role_permissions (Alembic 0024), role_template(role, db),
GET/PUT /api/waiters/roles/{role}/permissions applying the change to everyone
with the role; manager Settings -> Operation -> "What each role may do".
0024 also grants the new key to existing owners and store managers.
- Bootstrap `approvable`; @xenia/access useAllowed(key) -> yes/approve/no.
The waiter shows each action by key, "with a manager's approval (PIN)" where
allowed; GET /api/orders/cancel-permissions removed.
- Tests: test_waiter_keys.py (11), access allowed(), waiter.mjs +5, manager.mjs +3.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,8 @@ PUT /modules/{key} enable/disable a module; applies at once (D-19).
|
||||
Agent notes:
|
||||
- `permissions` = the keys the caller holds (user_permissions; superadmin: all, D-7),
|
||||
limited in bootstrap to effective modules.
|
||||
- `approvable` = keys the caller lacks that a manager may approve (Perm overridable,
|
||||
effective modules): the apps show those actions and let the approval dialog run (4.3).
|
||||
- Access: PUT needs core.modules.manage (owner template).
|
||||
- `entitled`/`entitlement`/limit `value` come from core/modules/entitlements.py (step 1.4).
|
||||
"""
|
||||
@@ -120,6 +122,7 @@ def bootstrap(
|
||||
"user": None,
|
||||
"language": i18n.venue_language(),
|
||||
"permissions": [],
|
||||
"approvable": [],
|
||||
}
|
||||
if user is not None:
|
||||
out["user"] = {"id": user.id, "username": user.username, "full_name": user.full_name,
|
||||
@@ -127,6 +130,12 @@ def bootstrap(
|
||||
out["language"] = i18n.user_language(user)
|
||||
out["permissions"] = [k for k in permission_keys_for(user)
|
||||
if all_permissions()[k][1] in effective]
|
||||
# keys the user lacks that a manager may approve on the spot (D-10): the apps offer
|
||||
# those actions and the approval dialog does the rest (plan step 4.3)
|
||||
held = set(out["permissions"])
|
||||
out["approvable"] = sorted(k for k, (p, m) in all_permissions().items()
|
||||
if p.overridable and m in effective and k not in held
|
||||
and getattr(user, "role", None) != "superadmin")
|
||||
return out
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user