feat: Implement widget-feature assignment management in admin dashboard
Deploy Development / deploy (push) Successful in 53s
Build Test / lint-backend (push) Successful in 0s
Build Test / build-frontend (push) Successful in 15s

- Added new API endpoints for listing and updating widget-feature assignments, allowing for custom feature requirements.
- Introduced a new admin page for managing widget-feature assignments, enhancing the admin interface.
- Updated navigation to include a link to the new widget-feature assignments page.
- Refactored widget access logic to support AND-based feature requirements for widgets.
- Bumped app_dashboard version to 1.11.0 to reflect these changes and improvements.
This commit is contained in:
Lars committed 2026-04-08 12:26:28 +02:00
1 parent 365ce49c6a
commit 24daeeb83c
10 files changed
+498 -13

No files matched your search

+9 -9
View File
@@ -9,6 +9,7 @@ import copy
from typing import Any
from widget_catalog import WIDGET_CATALOG
from widget_feature_requirements_db import get_widget_required_feature_ids
def _check_feature_access(profile_id: str, feature_id: str, conn) -> dict:
@@ -21,13 +22,15 @@ _WIDGET_ENTRY_BY_ID: dict[str, dict[str, Any]] = {e["id"]: e for e in WIDGET_CAT
def widget_id_allowed(widget_id: str, profile_id: str, conn) -> bool:
entry = _WIDGET_ENTRY_BY_ID.get(widget_id)
if entry is None:
if _WIDGET_ENTRY_BY_ID.get(widget_id) is None:
return False
fid = entry.get("requires_feature")
if not fid:
fids = get_widget_required_feature_ids(widget_id, conn)
if not fids:
return True
return bool(_check_feature_access(profile_id, fid, conn)["allowed"])
for fid in fids:
if not _check_feature_access(profile_id, fid, conn)["allowed"]:
return False
return True
def _public_row(entry: dict[str, Any], *, allowed: bool) -> dict[str, Any]:
@@ -43,10 +46,7 @@ def widgets_catalog_for_profile(profile_id: str, conn) -> list[dict[str, Any]]:
"""Zeilen für GET /api/app/widgets/catalog (ohne internes requires_feature-Feld)."""
out: list[dict[str, Any]] = []
for e in WIDGET_CATALOG:
fid = e.get("requires_feature")
allowed = True
if fid:
allowed = bool(_check_feature_access(profile_id, fid, conn)["allowed"])
allowed = widget_id_allowed(e["id"], profile_id, conn)
out.append(_public_row(e, allowed=allowed))
return out