Implement Club Feature Quota Bypass and Update Versioning
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 42s
Test Suite / playwright-tests (push) Successful in 1m19s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 2s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 13s
Test Suite / k6 /health Baseline (push) Successful in 42s
Test Suite / playwright-tests (push) Successful in 1m19s
- Added support for club feature quota bypass based on portal roles and profile grants in the capabilities check. - Introduced new functions to handle quota bypass logic in club feature access and consumption. - Updated the FeatureUsageBadge component to reflect platform exemptions for features. - Incremented application version to 0.8.195 and database schema version to 20260606083 to reflect these changes. - Enhanced backend routers to include new logic for consuming club features during AI-related actions.
This commit is contained in:
1 parent
fa10450315
commit
8404a42b6c
16 files changed
+1063
-41
No files matched your search
@@ -328,6 +328,7 @@ def probe_club_feature_access(
|
||||
action: str,
|
||||
club_id: Optional[int] = None,
|
||||
profile_id: Optional[int] = None,
|
||||
portal_role: Optional[str] = None,
|
||||
endpoint: Optional[str] = None,
|
||||
conn=None,
|
||||
) -> Dict[str, Any]:
|
||||
@@ -358,11 +359,29 @@ def probe_club_feature_access(
|
||||
)
|
||||
return access
|
||||
|
||||
def _resolve_access(connection):
|
||||
from club_quota_bypass import is_club_feature_quota_bypassed, quota_bypass_access
|
||||
|
||||
cur = get_cursor(connection)
|
||||
if is_club_feature_quota_bypassed(
|
||||
cur,
|
||||
profile_id=profile_id,
|
||||
portal_role=portal_role,
|
||||
feature_id=feature_id,
|
||||
):
|
||||
plan_id = get_effective_club_plan(cur, int(club_id))
|
||||
return quota_bypass_access(
|
||||
feature_id=feature_id,
|
||||
club_id=int(club_id),
|
||||
plan_id=plan_id,
|
||||
)
|
||||
return check_club_feature_access(club_id, feature_id, conn=connection)
|
||||
|
||||
if conn is not None:
|
||||
access = check_club_feature_access(club_id, feature_id, conn=conn)
|
||||
access = _resolve_access(conn)
|
||||
else:
|
||||
with get_db() as c:
|
||||
access = check_club_feature_access(club_id, feature_id, conn=c)
|
||||
access = _resolve_access(c)
|
||||
|
||||
log_club_feature_usage(
|
||||
club_id=club_id,
|
||||
@@ -387,6 +406,58 @@ def probe_club_feature_access(
|
||||
return access
|
||||
|
||||
|
||||
def consume_club_feature(
|
||||
*,
|
||||
feature_id: str,
|
||||
club_id: Optional[int],
|
||||
profile_id: Optional[int] = None,
|
||||
portal_role: Optional[str] = None,
|
||||
action: Optional[str] = None,
|
||||
amount: int = 1,
|
||||
conn=None,
|
||||
) -> None:
|
||||
"""
|
||||
Phase 4 (M5): Zähler nach erfolgreichem Verbrauch erhöhen.
|
||||
Nur wenn club_id gesetzt (Vereins-Kontingent); amount = Anzahl LLM/API-Verbrauchseinheiten.
|
||||
Plattform-Ausnahmen (superadmin, konfigurierte Rollen/Profile) werden nicht gezählt.
|
||||
"""
|
||||
if club_id is None:
|
||||
return
|
||||
|
||||
def _is_exempt(connection) -> bool:
|
||||
from club_quota_bypass import is_club_feature_quota_bypassed
|
||||
|
||||
cur = get_cursor(connection)
|
||||
return is_club_feature_quota_bypassed(
|
||||
cur,
|
||||
profile_id=profile_id,
|
||||
portal_role=portal_role,
|
||||
feature_id=feature_id,
|
||||
)
|
||||
|
||||
if conn is not None:
|
||||
if _is_exempt(conn):
|
||||
return
|
||||
else:
|
||||
with get_db() as c:
|
||||
if _is_exempt(c):
|
||||
return
|
||||
try:
|
||||
n = int(amount)
|
||||
except (TypeError, ValueError):
|
||||
n = 1
|
||||
if n < 1:
|
||||
return
|
||||
for _ in range(n):
|
||||
increment_club_feature_usage(
|
||||
int(club_id),
|
||||
feature_id,
|
||||
profile_id=profile_id,
|
||||
action=action,
|
||||
conn=conn,
|
||||
)
|
||||
|
||||
|
||||
def increment_club_feature_usage(
|
||||
club_id: int,
|
||||
feature_id: str,
|
||||
|
||||
Reference in new issue
Block a user