Sprint 1: Stammdaten-Modelle/-Endpunkte, Admin-Benutzerverwaltung, Zuständigkeits-Vererbung (E2)
CI / backend-tests (push) Failing after 0s

- ORM-Modelle: Bereich, Kategorie, Standort, Objekttyp, Material (Prompt 06/07),
  minimales Objekt-Modell (voll ausgebaut erst Sprint 2), Zustaendigkeit/
  Kontrollverantwortung
- Admin-API 7a: GET/POST Stammdaten-Endpunkte, PATCH Material, Benutzerverwaltung
  (anlegen/Rollen ändern), Zuständigkeits-/Kontrollverantwortungs-CRUD
- Vererbungslogik E2 als eigener Service (app/services/zustaendigkeit.py):
  Standort-Zuordnung vererbt sich auf alle Objekte, Objekt-Zeile ist Vereinigung
  statt Ersatz - GET /zustaendigkeiten/benutzer/{id}/objekte exponiert das
- Tests: Stammdaten-CRUD + Rollenrechte, Benutzerverwaltung (inkl. 409 bei
  Login-Duplikat), E2-Vererbungslogik (Standort-only, Standort+Objekt-Vereinigung,
  End-to-End über den Endpunkt)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L85hmKbvX7Cqkq47KnQhFt
This commit is contained in:
2026-09-03 23:12:49 +02:00
co-authored by Claude Sonnet 5
parent 035b22fd1e
commit b9cf195a63
19 changed files with 937 additions and 2 deletions
View File
+35
View File
@@ -0,0 +1,35 @@
from pydantic import BaseModel, ConfigDict
from app.models.auth import RolleTyp
class BenutzerCreate(BaseModel):
name: str
login: str
passwort: str
rollen: list[RolleTyp] = []
class BenutzerRead(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
name: str
login: str
aktiv: bool
rollen: list[str]
@classmethod
def from_orm_benutzer(cls, benutzer) -> "BenutzerRead":
return cls(
id=benutzer.id,
name=benutzer.name,
login=benutzer.login,
aktiv=benutzer.aktiv,
rollen=benutzer.rollen_namen,
)
class BenutzerUpdate(BaseModel):
name: str | None = None
aktiv: bool | None = None
rollen: list[RolleTyp] | None = None
+76
View File
@@ -0,0 +1,76 @@
from pydantic import BaseModel, ConfigDict
from app.models.stammdaten import MaterialTyp
class BereichCreate(BaseModel):
name: str
beschreibung: str | None = None
class BereichRead(BereichCreate):
model_config = ConfigDict(from_attributes=True)
id: int
class KategorieCreate(BaseModel):
bereich_id: int
name: str
ueberkategorie_id: int | None = None
class KategorieRead(KategorieCreate):
model_config = ConfigDict(from_attributes=True)
id: int
class StandortCreate(BaseModel):
name: str
adresse: str | None = None
class StandortRead(StandortCreate):
model_config = ConfigDict(from_attributes=True)
id: int
class ObjekttypCreate(BaseModel):
bereich_id: int
kategorie_id: int | None = None
name: str
class ObjekttypRead(ObjekttypCreate):
model_config = ConfigDict(from_attributes=True)
id: int
class MaterialCreate(BaseModel):
name: str
artikelnummer: str | None = None
einheit: str
materialtyp: MaterialTyp
kategorie_id: int | None = None
hersteller: str | None = None
beschreibung: str | None = None
code: str | None = None
warnzeitraum_tage: int | None = None
aktiv: bool = True
class MaterialUpdate(BaseModel):
name: str | None = None
artikelnummer: str | None = None
einheit: str | None = None
materialtyp: MaterialTyp | None = None
kategorie_id: int | None = None
hersteller: str | None = None
beschreibung: str | None = None
code: str | None = None
warnzeitraum_tage: int | None = None
aktiv: bool | None = None
class MaterialRead(MaterialCreate):
model_config = ConfigDict(from_attributes=True)
id: int
+45
View File
@@ -0,0 +1,45 @@
import uuid
from pydantic import BaseModel, ConfigDict, model_validator
class ZustaendigkeitCreate(BaseModel):
benutzer_id: int
standort_id: int | None = None
objekt_id: int | None = None
@model_validator(mode="after")
def _standort_oder_objekt(self) -> "ZustaendigkeitCreate":
if self.standort_id is None and self.objekt_id is None:
raise ValueError("Entweder standort_id oder objekt_id muss gesetzt sein.")
return self
class ZustaendigkeitRead(ZustaendigkeitCreate):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
class KontrollverantwortungCreate(BaseModel):
objekt_id: int
benutzer_id: int | None = None
gruppe: str | None = None
@model_validator(mode="after")
def _person_oder_gruppe(self) -> "KontrollverantwortungCreate":
if self.benutzer_id is None and self.gruppe is None:
raise ValueError("Entweder benutzer_id oder gruppe muss gesetzt sein.")
return self
class KontrollverantwortungRead(KontrollverantwortungCreate):
model_config = ConfigDict(from_attributes=True)
id: uuid.UUID
class ObjektKurz(BaseModel):
model_config = ConfigDict(from_attributes=True)
id: int
code: str
name: str
standort_id: int