Lass E-Mails ueber die Faecher finden und halte Kapitel sowie das Menue in der Akte an ihrem Ort.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3465ed57f6
commit
67d48378c9
11 files changed
+696
-160
No files matched your search
+49
-28
@@ -358,6 +358,32 @@ def matter_placements(conn, actor: UUID, matter_id: UUID, context: Ctx | None) -
|
||||
return items
|
||||
|
||||
|
||||
def _contained_group(conn, actor: UUID, matter: dict, context: Ctx) -> dict | None:
|
||||
matter_right = matter_rights(conn, actor, matter, context)
|
||||
if not matter_right.read:
|
||||
return None
|
||||
return {
|
||||
"matter_id": str(matter["id"]),
|
||||
"title": matter["title"],
|
||||
"kind_label": "Teilvorgang" if matter["parent_matter_id"] else "Vorgang",
|
||||
"parent_title": matter_title_if_readable(conn, actor, matter["parent_matter_id"]),
|
||||
"version": matter["version"],
|
||||
"rights": matter_right.as_dict(),
|
||||
"chapters": _chapters(conn, "matter", matter["id"]),
|
||||
"content_order": matter.get("content_order") or "position",
|
||||
"content_order_dir": matter.get("content_order_dir") or "asc",
|
||||
"bindings": _ordered_bindings(
|
||||
conn,
|
||||
actor,
|
||||
"matter",
|
||||
matter["id"],
|
||||
context,
|
||||
matter.get("content_order") or "position",
|
||||
matter.get("content_order_dir") or "asc",
|
||||
),
|
||||
}
|
||||
|
||||
|
||||
def _matter_node(row: dict) -> dict:
|
||||
return {
|
||||
"id": str(row["id"]),
|
||||
@@ -461,7 +487,8 @@ def case_detail(conn, actor: UUID, case: dict, rights) -> dict:
|
||||
conn, actor, "case", case["id"], context, payload["content_order"], payload["content_order_dir"]
|
||||
)
|
||||
contained = []
|
||||
for link in conn.execute(
|
||||
seen_matters: set[UUID] = set()
|
||||
linked_matters = conn.execute(
|
||||
"""
|
||||
SELECT m.*
|
||||
FROM matter_case_links l
|
||||
@@ -470,33 +497,27 @@ def case_detail(conn, actor: UUID, case: dict, rights) -> dict:
|
||||
ORDER BY m.title, m.id
|
||||
""",
|
||||
(case["id"],),
|
||||
).fetchall():
|
||||
matter_right = matter_rights(conn, actor, link, context)
|
||||
if not matter_right.read:
|
||||
continue
|
||||
items = _ordered_bindings(
|
||||
conn,
|
||||
actor,
|
||||
"matter",
|
||||
link["id"],
|
||||
context,
|
||||
link.get("content_order") or "position",
|
||||
link.get("content_order_dir") or "asc",
|
||||
)
|
||||
if not items:
|
||||
continue
|
||||
contained.append(
|
||||
{
|
||||
"matter_id": str(link["id"]),
|
||||
"title": link["title"],
|
||||
"version": link["version"],
|
||||
"rights": matter_right.as_dict(),
|
||||
"chapters": _chapters(conn, "matter", link["id"]),
|
||||
"content_order": link.get("content_order") or "position",
|
||||
"content_order_dir": link.get("content_order_dir") or "asc",
|
||||
"bindings": items,
|
||||
}
|
||||
)
|
||||
).fetchall()
|
||||
for link in linked_matters:
|
||||
block = [link]
|
||||
if not link["parent_matter_id"]:
|
||||
block.extend(
|
||||
conn.execute(
|
||||
"""
|
||||
SELECT * FROM matters
|
||||
WHERE parent_matter_id = %s AND deleted_at IS NULL
|
||||
ORDER BY title, id
|
||||
""",
|
||||
(link["id"],),
|
||||
).fetchall()
|
||||
)
|
||||
for matter in block:
|
||||
if matter["id"] in seen_matters:
|
||||
continue
|
||||
seen_matters.add(matter["id"])
|
||||
group = _contained_group(conn, actor, matter, context)
|
||||
if group is not None:
|
||||
contained.append(group)
|
||||
payload["contained"] = contained
|
||||
payload["tasks"] = []
|
||||
payload["deadlines"] = []
|
||||
|
||||
Reference in new issue
Block a user