AP1.10b/10c: Entity Field System mit dynamischen Vorhaben-Zusatzfeldern.
Deploy Development / deploy (push) Successful in 44s
Test Suite / pytest-backend (push) Successful in 1m54s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 15s

EFS-Tabellen, Registry-Sync und Fields-API ermöglichen archetyp-spezifische Felder; Frontend rendert sie im Profil-Modal per FieldRenderer.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-09 13:53:07 +02:00
1 parent 408050bcb8
commit a6fc86025c
23 files changed
+1107 -20

No files matched your search

+38 -2
View File
@@ -1,9 +1,13 @@
"""System-Archetypen (AP1.10a) — Seed-Daten bis EFS-Tabellen (10b)."""
"""System-Archetypen (AP1.10a/10b) — In-Memory-Seed + DB-Registry."""
from __future__ import annotations
from typing import Any, Optional
from psycopg2.extras import RealDictCursor
from db import get_connection
INITIATIVE_ARCHETYPES: tuple[dict[str, Any], ...] = (
{
"key": "initiative.generic",
@@ -33,12 +37,44 @@ _ARCHETYPE_INDEX = {
}
def list_archetypes(*, entity_type: Optional[str] = None) -> list[dict[str, Any]]:
def _list_archetypes_from_memory(*, entity_type: Optional[str] = None) -> list[dict[str, Any]]:
if entity_type is None:
return [dict(item) for item in INITIATIVE_ARCHETYPES]
return [dict(item) for item in INITIATIVE_ARCHETYPES if item["entity_type"] == entity_type]
def list_archetypes(*, entity_type: Optional[str] = None) -> list[dict[str, Any]]:
conn = get_connection()
try:
with conn.cursor(cursor_factory=RealDictCursor) as cur:
if entity_type is None:
cur.execute(
"""
SELECT archetype_key AS key, entity_type, label, description, is_system
FROM entity_archetypes
ORDER BY entity_type ASC, archetype_key ASC
"""
)
else:
cur.execute(
"""
SELECT archetype_key AS key, entity_type, label, description, is_system
FROM entity_archetypes
WHERE entity_type = %s
ORDER BY archetype_key ASC
""",
(entity_type,),
)
rows = cur.fetchall()
if rows:
return [dict(row) for row in rows]
except Exception:
pass
finally:
conn.close()
return _list_archetypes_from_memory(entity_type=entity_type)
def validate_archetype_key(*, entity_type: str, archetype_key: str) -> None:
if (entity_type, archetype_key) not in _ARCHETYPE_INDEX:
raise ValueError(f"Unbekannter Archetyp: {archetype_key}")