diff --git a/backend/app/api/routes.py b/backend/app/api/routes.py
index 7ba878a..0e2e573 100644
--- a/backend/app/api/routes.py
+++ b/backend/app/api/routes.py
@@ -15,6 +15,7 @@ from app.access.policy import (
case_rights,
deadline_rights,
element_rights,
+ ensure_member_or_personal,
get_case,
get_deadline,
get_element,
@@ -22,6 +23,7 @@ from app.access.policy import (
get_task,
list_cases,
list_matters,
+ room_name,
matter_rights,
parse_context,
parse_query_context,
@@ -119,6 +121,15 @@ router = APIRouter()
_login_attempts: dict[str, list[datetime]] = {}
+def _chosen_home(conn, principal: Principal, requested: UUID | None) -> UUID:
+ scope_id = requested or principal.scope_id
+ room = conn.execute("SELECT id, kind FROM data_rooms WHERE id = %s", (scope_id,)).fetchone()
+ if room is None:
+ raise not_found()
+ ensure_member_or_personal(conn, principal.account_id, room["kind"], room["id"])
+ return room["id"]
+
+
def _created(path: str, payload: dict) -> JSONResponse:
return JSONResponse(status_code=201, content=payload, headers={"Location": path})
@@ -412,13 +423,24 @@ def find_principal(email: str, principal: Principal = Depends(get_principal), co
@router.get("/api/v1/cases")
def cases(principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
- items = [case_summary(case, rights) for case, rights in list_cases(conn, principal.account_id)]
+ items = []
+ for case, rights in list_cases(conn, principal.account_id):
+ summary = case_summary(case, rights)
+ summary["home_scope_name"] = room_name(conn, case["home_scope_id"])
+ items.append(summary)
return {"items": items, "next_cursor": None}
@router.post("/api/v1/cases")
def post_case(body: CaseIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
- case = create_case(conn, principal.account_id, principal.scope_id, body.title, body.parent_case_id, body.rights_mode)
+ case = create_case(
+ conn,
+ principal.account_id,
+ _chosen_home(conn, principal, body.home_scope_id),
+ body.title,
+ body.parent_case_id,
+ body.rights_mode,
+ )
rights = case_rights(conn, principal.account_id, case)
return _created(f"/api/v1/cases/{case['id']}", case_summary(case, rights))
@@ -477,7 +499,12 @@ def matters(principal: Principal = Depends(get_principal), conn: Connection = De
@router.post("/api/v1/matters")
def post_matter(body: MatterIn, principal: Principal = Depends(get_principal), conn: Connection = Depends(get_conn)):
matter = create_matter(
- conn, principal.account_id, principal.scope_id, body.title, body.parent_matter_id, _ctx_model(body.context)
+ conn,
+ principal.account_id,
+ _chosen_home(conn, principal, body.home_scope_id),
+ body.title,
+ body.parent_matter_id,
+ _ctx_model(body.context),
)
return _created(f"/api/v1/matters/{matter['id']}", matter_summary(conn, principal.account_id, matter))
diff --git a/backend/app/api/schemas.py b/backend/app/api/schemas.py
index 2d3d5b0..22f57f1 100644
--- a/backend/app/api/schemas.py
+++ b/backend/app/api/schemas.py
@@ -54,6 +54,7 @@ class CaseIn(APIModel):
title: str = Field(min_length=1, max_length=200)
parent_case_id: UUID | None = None
rights_mode: Literal["inherit_parent", "explicit"] = "inherit_parent"
+ home_scope_id: UUID | None = None
class CasePatch(APIModel):
@@ -71,6 +72,7 @@ class MatterIn(APIModel):
title: str = Field(min_length=1, max_length=200)
parent_matter_id: UUID | None = None
context: ContextIn | None = None
+ home_scope_id: UUID | None = None
class MatterPatch(APIModel):
diff --git a/backend/app/present.py b/backend/app/present.py
index e4c729e..0c57408 100644
--- a/backend/app/present.py
+++ b/backend/app/present.py
@@ -268,6 +268,7 @@ def matter_summary(conn, actor: UUID, matter: dict) -> dict:
"version": matter["version"],
"parent_matter_id": str(matter["parent_matter_id"]) if matter["parent_matter_id"] else None,
"home_scope_id": str(matter["home_scope_id"]),
+ "home_scope_name": room_name(conn, matter["home_scope_id"]),
"contexts": matter_contexts(conn, actor, matter),
}
diff --git a/frontend/src/pages/Cases.jsx b/frontend/src/pages/Cases.jsx
index d0fcc79..02573a4 100644
--- a/frontend/src/pages/Cases.jsx
+++ b/frontend/src/pages/Cases.jsx
@@ -10,6 +10,8 @@ export function CaseList() {
const { session } = useContext(SessionContext);
const [items, setItems] = useState([]);
const [title, setTitle] = useState("");
+ const [roomId, setRoomId] = useState(session.rooms[0]?.id || "");
+ const [roomFilter, setRoomFilter] = useState("");
const [error, setError] = useState("");
const [creating, setCreating] = useState(false);
@@ -26,7 +28,7 @@ export function CaseList() {
event.preventDefault();
setError("");
try {
- await api("/api/v1/cases", { method: "POST", body: { title } });
+ await api("/api/v1/cases", { method: "POST", body: { title, home_scope_id: roomId } });
setTitle("");
markDirty(false);
setCreating(false);
@@ -41,16 +43,24 @@ export function CaseList() {
Eine Akte sammelt die Vorgänge. Neu angelegt wird sie in „{session.scope.name}“. Eine Akte sammelt die Vorgänge. Der Datenraum an der Akte bestimmt, wer sie sieht.Akten
-