Lege Einstellungen je Konto mit Erbung vom Hauptnutzer an und biete die Prüfstufe für doppelte Dokumente in Mein Konto an.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
StommerandClaude Sonnet 5.5 committed 2026-10-25 09:18:17 +01:00
1 parent bee48bf4a5
commit a6dc24d8fe
11 files changed
+339 -1

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
"""Account preferences: read the effective value, change the own value, bind the team."""
from __future__ import annotations
from fastapi import APIRouter, Depends
from fastapi.responses import JSONResponse
from psycopg import Connection
from app.access.policy import audit
from app.api.deps import Principal, get_conn, get_principal
from app.api.schemas import PreferenceIn
from app.preferences import preference_state, store_preference
router = APIRouter()
_NO_STORE = {"Cache-Control": "no-store"}
@router.get("/api/v1/auth/preferences/{key}")
def get_preference(key: str, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
return JSONResponse(preference_state(conn, principal.account_id, key), headers=_NO_STORE)
@router.put("/api/v1/auth/preferences/{key}")
def put_preference(
key: str,
body: PreferenceIn,
principal: Principal = Depends(get_principal),
conn: Connection = Depends(get_conn),
):
state = store_preference(conn, principal.account_id, key, body.value, body.team_mode)
audit(
conn,
principal.account_id,
None,
"preference_changed",
"account",
principal.account_id,
detail={"key": key, "value": body.value, "team_mode": body.team_mode},
)
return JSONResponse(state, headers=_NO_STORE)
+7
View File
@@ -521,6 +521,13 @@ class DispatchCorrectIn(APIModel):
clear_counterpart: bool = False
class PreferenceIn(APIModel):
"""`value` replaces the own value; null means: inherit. `team_mode` is for main users and stays as it is when absent."""
value: str | None = Field(default=None, max_length=40)
team_mode: Literal["free", "locked"] | None = None
class DownloadPolicyIn(APIModel):
"""Who may save or open the original outside of Tsumugu. `direct` only applies to the account default."""