feat: enhance SQL query handling and UI components for exercise management
Deploy Development / deploy (push) Successful in 36s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 5s
Test Suite / playwright-tests (push) Has been cancelled

- Introduced a new utility function to streamline SQL query construction for active status filtering, improving code reusability across multiple endpoints.
- Updated existing query logic in the catalogs and skills routers to utilize the new utility function, ensuring consistent handling of active status.
- Refactored the ExerciseFormPage to remove deprecated age group handling, simplifying the form structure.
- Enhanced the RichTextEditor component with improved link handling and formatting options for better user experience.
- Updated API utility functions to support new AI features for exercise suggestions and regeneration, expanding the capabilities of the exercise management system.
This commit is contained in:
Lars committed 2026-04-27 15:01:47 +02:00
1 parent d8f439a3e5
commit 0ad096e483
7 files changed
+129 -84

No files matched your search

+27 -12
View File
@@ -14,6 +14,17 @@ from auth import require_auth
router = APIRouter(prefix="/api", tags=["catalogs"])
def _sql_active_status(column: str, status: Optional[str]) -> tuple[str, list]:
"""
Filter „active“ schließt Legacy-Zeilen mit status IS NULL ein (sonst leere Dropdowns in der UI).
"""
if not status:
return "", []
if status == "active":
return f" ({column} = 'active' OR {column} IS NULL)", []
return f" ({column} = %s)", [status]
def _slugify_skill_label(text: str) -> str:
t = (text or "").strip().lower()
t = re.sub(r"[^a-z0-9äöüß]+", "_", t, flags=re.IGNORECASE)
@@ -155,9 +166,10 @@ def list_focus_areas(
query = "SELECT * FROM focus_areas"
params = []
if status:
query += " WHERE status = %s"
params.append(status)
frag, extra = _sql_active_status("status", status)
if frag:
query += " WHERE" + frag
params.extend(extra)
query += " ORDER BY sort_order, name"
@@ -275,9 +287,10 @@ def list_training_styles(
"""
params = []
if status:
query += " WHERE ts.status = %s"
params.append(status)
frag, extra = _sql_active_status("ts.status", status)
if frag:
query += " WHERE" + frag
params.extend(extra)
query += " ORDER BY ts.sort_order, ts.name"
@@ -517,9 +530,10 @@ def list_training_types(
params = []
where = []
if status:
where.append("tt.status = %s")
params.append(status)
frag, extra = _sql_active_status("tt.status", status)
if frag:
where.append(frag.strip())
params.extend(extra)
if focus_area_id is not None:
where.append("tt.focus_area_id = %s")
@@ -955,9 +969,10 @@ def list_target_groups(
params = []
where = []
if status:
where.append("status = %s")
params.append(status)
frag, extra = _sql_active_status("status", status)
if frag:
where.append(frag.strip())
params.extend(extra)
if where:
query += " WHERE " + " AND ".join(where)
+7 -4
View File
@@ -53,11 +53,14 @@ def list_skills(
params.append(category)
if status:
where.append("status = %s")
params.append(status)
if status == "active":
where.append("(status = 'active' OR status IS NULL)")
else:
where.append("status = %s")
params.append(status)
else:
# Default: only active skills
where.append("status = 'active'")
# Default: nur aktive (NULL = Legacy, wie Kataloglisten)
where.append("(status = 'active' OR status IS NULL)")
if where:
query += " WHERE " + " AND ".join(where)