Some checks failed
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Failing after 0s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Failing after 4m0s
Test Suite / playwright-tests (push) Failing after 3m41s
- Introduced `email_verified` and `account_state` attributes in the `TenantContext` to improve user state management. - Updated the `resolve_tenant_context` function to dynamically fetch `email_verified` status from the database and determine `account_state` based on user roles and memberships. - Implemented `assert_min_account_state` checks across various endpoints to enforce access control based on user account status. - Incremented version to 1.1.0 in version.py to reflect these enhancements in tenant context management and access control.
73 lines
2.7 KiB
Python
73 lines
2.7 KiB
Python
"""
|
|
POST /api/planning/exercise-suggest — planungsgebundene Übungssuche (Hybrid + Profil + optional LLM-Rerank).
|
|
"""
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from db import get_db, get_cursor
|
|
from tenant_context import TenantContext, get_tenant_context
|
|
from planning_exercise_suggest import PlanningExerciseSuggestRequest, suggest_planning_exercises
|
|
from planning_exercise_path_builder import ProgressionPathSuggestRequest, suggest_progression_path
|
|
from account_lifecycle import assert_min_account_state
|
|
from capabilities import probe_capability
|
|
from club_features import probe_club_feature_access, resolve_club_id_for_probe
|
|
|
|
router = APIRouter(prefix="/api/planning", tags=["planning_exercise_suggest"])
|
|
|
|
|
|
@router.post("/exercise-suggest")
|
|
def post_planning_exercise_suggest(
|
|
body: PlanningExerciseSuggestRequest,
|
|
tenant: TenantContext = Depends(get_tenant_context),
|
|
):
|
|
if body.include_llm_intent or body.include_llm_rank:
|
|
assert_min_account_state(tenant, "active_member", endpoint="POST /planning/exercise-suggest")
|
|
probe_capability(
|
|
tenant,
|
|
"planning.ai.suggest",
|
|
action="planning_suggest",
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
endpoint="POST /planning/exercise-suggest",
|
|
)
|
|
probe_club_feature_access(
|
|
feature_id="ai_calls",
|
|
action="planning_suggest",
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
profile_id=tenant.profile_id,
|
|
endpoint="POST /planning/exercise-suggest",
|
|
)
|
|
with get_db() as conn:
|
|
cur = get_cursor(conn)
|
|
return suggest_planning_exercises(cur, tenant=tenant, body=body)
|
|
|
|
|
|
@router.post("/progression-path-suggest")
|
|
def post_progression_path_suggest(
|
|
body: ProgressionPathSuggestRequest,
|
|
tenant: TenantContext = Depends(get_tenant_context),
|
|
):
|
|
if (
|
|
body.include_llm_intent
|
|
or body.include_llm_path_qa
|
|
or body.include_ai_gap_fill
|
|
):
|
|
assert_min_account_state(
|
|
tenant, "active_member", endpoint="POST /planning/progression-path-suggest"
|
|
)
|
|
probe_capability(
|
|
tenant,
|
|
"planning.ai.progression_path",
|
|
action="progression_path_suggest",
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
endpoint="POST /planning/progression-path-suggest",
|
|
)
|
|
probe_club_feature_access(
|
|
feature_id="ai_calls",
|
|
action="progression_path_suggest",
|
|
club_id=resolve_club_id_for_probe(tenant),
|
|
profile_id=tenant.profile_id,
|
|
endpoint="POST /planning/progression-path-suggest",
|
|
)
|
|
with get_db() as conn:
|
|
cur = get_cursor(conn)
|
|
return suggest_progression_path(cur, tenant=tenant, body=body)
|