Ordne Anlagen und Belege im Übergabepaket pro Hauptschriftstück zu.
Deploy Development / deploy (push) Successful in 28s
Test Suite / pytest-backend (push) Failing after 1m38s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 9s

Statt gemeinsamem anlagen-arbeitsstand und Datumsordnern auf Kapitel-Ebene liegen zugeordnete Dateien unter Dokumentname/Anlagen bzw. Belege, damit mehrere Schreiben im gleichen Kapitel vollständig und eindeutig exportiert werden.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 14:32:05 +02:00
1 parent 5b23e4aab0
commit 2b23992a1a
3 files changed
+152 -7

No files matched your search

+129
View File
@@ -777,3 +777,132 @@ def test_nested_chapter_export_keeps_path_and_complete_mail(client, db, monkeypa
assert overview.index("Anschreiben") < overview.index("Heizkostenbeleg")
assert "Hausmeisterbeleg" not in overview
assert "Ausgelassen" not in overview
def test_correspondence_attachments_stay_under_each_host_in_one_chapter(client, db):
ada = Actor(client, "ada-host-bundle@example.test", "Ada Host Bundle")
register(db, ada.email, ada.name)
ada.login()
matter = ada.request("POST", "/api/v1/matters", json={"title": "Gemeinsames Kapitel"}, status=201)
chapter = ada.request(
"POST",
f"/api/v1/matters/{matter['id']}/chapters",
json={"title": "Schriftwechsel"},
status=201,
)
first = ada.request(
"POST",
"/api/v1/notes",
json={
"title": "Erstes Schreiben",
"document": document("Text eins"),
"context": {"kind": "matter", "id": matter["id"]},
"chapter_id": chapter["id"],
},
status=201,
)
second = ada.request(
"POST",
"/api/v1/notes",
json={
"title": "Zweites Schreiben",
"document": document("Text zwei"),
"context": {"kind": "matter", "id": matter["id"]},
"chapter_id": chapter["id"],
},
status=201,
)
att_a1 = ada.request(
"POST",
"/api/v1/files",
data={"title": "Anlage A1", "context_kind": "matter", "context_id": matter["id"]},
files={"upload": ("a1.pdf", PDF_A, "application/pdf")},
status=201,
)
att_a2 = ada.request(
"POST",
"/api/v1/files",
data={"title": "Anlage A2", "context_kind": "matter", "context_id": matter["id"]},
files={"upload": ("a2.pdf", PDF_B, "application/pdf")},
status=201,
)
att_b1 = ada.request(
"POST",
"/api/v1/files",
data={"title": "Anlage B1", "context_kind": "matter", "context_id": matter["id"]},
files={"upload": ("b1.pdf", PDF_C, "application/pdf")},
status=201,
)
att_b2 = ada.request(
"POST",
"/api/v1/files",
data={"title": "Anlage B2", "context_kind": "matter", "context_id": matter["id"]},
files={"upload": ("a1.pdf", PDF_A, "application/pdf")},
status=201,
)
receipt = ada.request(
"POST",
"/api/v1/notes",
json={
"title": "Einlieferungsbeleg",
"document": document("Eingeliefert"),
"context": {"kind": "matter", "id": matter["id"]},
"dates": {"document_on": "2026-04-01"},
},
status=201,
)
detail = ada.request("GET", f"/api/v1/matters/{matter['id']}")
host_a = next(item for item in detail["bindings"] if item["element"]["title"] == "Erstes Schreiben")
host_b = next(item for item in detail["bindings"] if item["element"]["title"] == "Zweites Schreiben")
ada.request(
"POST",
f"/api/v1/elements/{first['id']}/attachments",
json={
"expected_version": host_a["element"]["version"],
"context": {"kind": "matter", "id": matter["id"]},
"attachment_element_ids": [att_a1["id"], att_a2["id"]],
"fold": "attachment",
},
status=201,
)
ada.request(
"POST",
f"/api/v1/elements/{second['id']}/attachments",
json={
"expected_version": host_b["element"]["version"],
"context": {"kind": "matter", "id": matter["id"]},
"attachment_element_ids": [att_b1["id"], att_b2["id"]],
"fold": "attachment",
},
status=201,
)
ada.request(
"POST",
f"/api/v1/elements/{first['id']}/dispatches",
json={
"expected_version": host_a["element"]["version"],
"context": {"kind": "matter", "id": matter["id"]},
"channel": "post",
"sent_on": "2026-04-02",
"counterpart": "Post",
"attachment_element_ids": [],
"evidence": [{"element_id": receipt["id"], "role": "submission", "fold": "keep"}],
},
status=201,
)
tree = ada.request("GET", f"/api/v1/matters/{matter['id']}/export-tree")["tree"]
selected = [
node["id"]
for node in _walk(tree)
if node["kind"] in {"binding", "attachment", "evidence"} and node["exportable"]
]
response = _post_zip(ada, matter["id"], {"context": {"kind": "matter", "id": matter["id"]}, "selected": selected})
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("\\", "/")]
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 not any(name.replace("\\", "/").startswith("01 Schriftwechsel/2026-04") for name in names)