Packe jeden Vorgangseintrag im Übergabe-ZIP in einen eigenen Titelordner.
Test Suite / smoke-dev (push) Waiting to run
Test Suite / frontend-build (push) Waiting to run
Deploy Development / deploy (push) Successful in 28s
Test Suite / pytest-backend (push) Has been cancelled

Hauptdatei, Anlagen und Belege liegen darin zusammen; der Exportname folgt dem angezeigten Titel mit Original-Endung. E-Mails behalten ihren bestehenden Ordner, ohne doppelte Titel-Ebene für Korrespondenz.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 14:41:43 +02:00
1 parent 2b23992a1a
commit 8b74e63417
2 files changed
+29 -15

No files matched your search

+23 -8
View File
@@ -588,18 +588,20 @@ def _emit_email(node, folder, add, rewrite, entries, loaded, notice_for, generat
def _emit_loose(node, prefix, add, entries, loaded, notice_for, generated: str, chosen: set[str]) -> None:
bundle = _binding_bundle(prefix, node) if node.kind == "binding" else prefix
if node.kind == "binding" and node.id in loaded and node.content_kind != "email":
payload = loaded[node.id]
if node.content_kind == "note":
path = add(prefix + [f"{_segment(node.title)}.md"], _note_markdown(node, str(payload), generated).encode("utf-8"))
path = add(bundle + [f"{_segment(node.title)}.md"], _note_markdown(node, str(payload), generated).encode("utf-8"))
entries.append(_entry(node, path, [], None))
elif isinstance(payload, FilePayload):
path = add(prefix + [payload.filename], payload.data)
entries.append(_entry(node, path, [(payload.filename, path)], None))
name = _handover_filename(node, payload.filename)
path = add(bundle + [name], payload.data)
entries.append(_entry(node, path, [(name, path)], None))
if node.kind == "binding":
for child in node.children:
if child.kind == "annotation" and child.id in loaded and not (node.content_kind == "email" and node.id in loaded):
path = add(prefix + [_annotation_filename(child, prefix)], _annotation_markdown(child).encode("utf-8"))
path = add(bundle + [_annotation_filename(child, bundle)], _annotation_markdown(child).encode("utf-8"))
entries.append(_entry(child, path, [], None))
elif node.kind == "annotation" and node.id in loaded:
path = add(prefix + [_annotation_filename(node, prefix)], _annotation_markdown(node).encode("utf-8"))
@@ -608,9 +610,22 @@ def _emit_loose(node, prefix, add, entries, loaded, notice_for, generated: str,
_emit_related(node, prefix, add, entries, loaded, notice_for, chosen, generated)
def _host_bundle(prefix: list[str], host: ExportNode) -> list[str]:
"""Correspondence files stay under the host title, not a shared chapter folder."""
return prefix + [_segment(host.title)]
def _binding_bundle(prefix: list[str], host: ExportNode) -> list[str]:
"""One folder per entry; the main file and correspondence sit inside it."""
if host.kind == "binding" and host.content_kind == "email":
return list(prefix)
if host.kind == "binding":
return [*prefix, _segment(host.title)]
return list(prefix)
def _handover_filename(node: ExportNode, original: str) -> str:
"""Readable name for recipients; file bytes stay unchanged."""
stem = _segment(node.title)
suffix = PurePosixPath(original or "").suffix
if suffix:
return f"{stem}{suffix}"
return stem or _file_segment(original)
def _related_bucket(node: ExportNode) -> str:
@@ -627,7 +642,7 @@ def _related_bucket(node: ExportNode) -> str:
def _emit_related(node, prefix, add, entries, loaded, notice_for, chosen, generated: str) -> None:
bundle = _host_bundle(prefix, node)
bundle = _binding_bundle(prefix, node)
for child in node.children:
if child.kind == "attachment" and child.id in chosen and child.id in loaded:
_emit_one(child, bundle + ["Anlagen"], add, entries, loaded, notice_for, generated)
+6 -7
View File
@@ -357,8 +357,7 @@ def test_handover_package_follows_the_confirmed_selection(client, db, monkeypatc
names = archive.namelist()
assert "index.html" in names and "inhalt.md" in names
assert any(name.startswith("01 Vertrag/") for name in names)
schrift_names = [name for name in names if name.startswith("02 Schrift/")]
assert schrift_names == ["02 Schrift/schreiben.pdf"]
assert any("02 Schrift/Schreiben-Datei/Schreiben-Datei.pdf" in name.replace("\\", "/") for name in names)
assert any("Nebenpunkt" in name and name.endswith("Teilnotiz.md") for name in names)
mail_names = [name for name in names if "Schreiben mit Anlagen" in name]
assert any(name.endswith("/nachricht.eml") for name in mail_names)
@@ -371,7 +370,7 @@ def test_handover_package_follows_the_confirmed_selection(client, db, monkeypatc
assert "Gespiegelte Anlage" not in whole
assert "Fremdtext" not in whole
assert "bleibt Bestandteil" in whole
note_file = next(name for name in names if name.endswith("/Vertragnotiz.md"))
note_file = next(name for name in names if name.endswith("/Vertragnotiz/Vertragnotiz.md"))
annotation_file = next(name for name in names if "Anmerkung zu Vertragnotiz" in name)
assert "Kontextvermerk speziell" not in archive.read(note_file).decode("utf-8")
assert "Kontextvermerk speziell" in archive.read(annotation_file).decode("utf-8")
@@ -761,7 +760,7 @@ def test_nested_chapter_export_keeps_path_and_complete_mail(client, db, monkeypa
response = _post_zip(ada, matter["id"], body)
assert response.status_code == 200, response.text
names = _archive(response.content).namelist()
heating = next(name for name in names if name.endswith("/heiz.pdf"))
heating = next(name for name in names if name.endswith("/Heizkostenbeleg/Heizkostenbeleg.pdf"))
assert heating.startswith(
"01 Nebenkostenabrechnung 2025/02 Übermittelte Abrechnungsunterlagen/01 Einzelbelege/"
)
@@ -900,9 +899,9 @@ def test_correspondence_attachments_stay_under_each_host_in_one_chapter(client,
assert response.status_code == 200, response.text
names = _archive(response.content).namelist()
assert not any("anlagen-arbeitsstand" in name.lower() for name in names)
first_paths = [name for name in names if "Erstes Schreiben/Erstes Schreiben/Anlagen/" in name.replace("\\", "/")]
second_paths = [name for name in names if "Zweites Schreiben/Zweites Schreiben/Anlagen/" in name.replace("\\", "/")]
first_paths = [name for name in names if "Erstes Schreiben/Anlagen/" in name.replace("\\", "/")]
second_paths = [name for name in names if "Zweites Schreiben/Anlagen/" in name.replace("\\", "/")]
assert sorted(name.rsplit("/", 1)[-1] for name in first_paths) == ["a1.pdf", "a2.pdf"]
assert sorted(name.rsplit("/", 1)[-1] for name in second_paths) == ["a1.pdf", "b1.pdf"]
assert any("Erstes Schreiben/Erstes Schreiben/Belege/" in name.replace("\\", "/") for name in names)
assert any("Erstes Schreiben/Belege/" in name.replace("\\", "/") for name in names)
assert not any(name.replace("\\", "/").startswith("01 Schriftwechsel/2026-04") for name in names)