Lege einen Beleg ohne Versandfassung ab und markiere das Zurueckziehen, damit der Drop an der Markierung ankommt und ein Nachweis kein E-Mail-Versand wird.
Deploy Development / deploy (push) Successful in 28s
Test Suite / pytest-backend (push) Successful in 2m0s
Test Suite / smoke-dev (push) Successful in 0s
Test Suite / frontend-build (push) Successful in 8s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-10-18 12:01:19 +02:00
1 parent 9f5327f3be
commit 7846830765
6 files changed
+241 -158

No files matched your search

+1
View File
@@ -146,6 +146,7 @@ def post_dispatch(
body.attachment_element_ids,
[item.model_dump() for item in body.evidence],
body.historical_gap,
body.capture_editions,
request.app.state.settings.media_root,
request.state.cleanup_files,
)
+1
View File
@@ -413,6 +413,7 @@ class DispatchIn(APIModel):
attachment_element_ids: list[UUID] = Field(default_factory=list, max_length=100)
evidence: list[EvidenceIn] = Field(default_factory=list, max_length=20)
historical_gap: bool = False
capture_editions: bool = True
class DispatchEvidenceIn(APIModel):
+30 -13
View File
@@ -196,11 +196,16 @@ def record_dispatch(
attachment_ids: list[UUID],
evidence: list[dict],
historical_gap: bool,
capture_editions: bool,
media_root: str,
cleanup: list[Path],
) -> dict:
if channel not in CHANNELS:
raise unprocessable("Der Versandweg ist nicht vorgesehen.")
if not capture_editions and attachment_ids:
raise unprocessable("Ein Beleg sichert das Schreiben nicht als Versandfassung.")
if not capture_editions and not evidence:
raise unprocessable("Ein Beleg braucht mindestens einen Nachweis.")
if len(attachment_ids) != len(set(attachment_ids)):
raise unprocessable("Dieselbe Anlage ist mehrfach im Versand genannt.")
container_row, page, scope = open_container(conn, actor, context, placement, "edit")
@@ -231,17 +236,19 @@ def record_dispatch(
actor,
),
).fetchone()
states = [_capture_item(conn, actor, dispatch, host, "host", 0, page, historical_gap, media_root, cleanup)]
ordered = [row for row in _uses(conn, scope, host_id) if row["attachment_element_id"] in set(attachment_ids)]
position_of = {item: index for index, item in enumerate(attachment_ids)}
ordered.sort(key=lambda row: position_of[row["attachment_element_id"]])
for index, row in enumerate(ordered, start=1):
element = _readable(conn, actor, row["attachment_element_id"], page)
if element is None:
raise not_found()
states.append(
_capture_item(conn, actor, dispatch, element, "attachment", index, page, historical_gap, media_root, cleanup)
)
states = []
if capture_editions:
states.append(_capture_item(conn, actor, dispatch, host, "host", 0, page, historical_gap, media_root, cleanup))
ordered = [row for row in _uses(conn, scope, host_id) if row["attachment_element_id"] in set(attachment_ids)]
position_of = {item: index for index, item in enumerate(attachment_ids)}
ordered.sort(key=lambda row: position_of[row["attachment_element_id"]])
for index, row in enumerate(ordered, start=1):
element = _readable(conn, actor, row["attachment_element_id"], page)
if element is None:
raise not_found()
states.append(
_capture_item(conn, actor, dispatch, element, "attachment", index, page, historical_gap, media_root, cleanup)
)
evidence_rows = []
for item in evidence:
evidence_rows.append(
@@ -260,7 +267,7 @@ def record_dispatch(
log=False,
)
)
completeness = _completeness(states)
completeness = _completeness(states) if capture_editions else "secured"
conn.execute(
"UPDATE dispatches SET completeness = %s, updated_at = now() WHERE id = %s",
(completeness, dispatch["id"]),
@@ -314,7 +321,16 @@ def detach_dispatch_evidence(
if deleted is None:
raise not_found()
_clear_evidence_fold(conn, scope, element_id)
_log(conn, dispatch_id, actor, "Nachweis aus diesem Versand gelöst")
leftover_evidence = conn.execute(
"SELECT id FROM dispatch_evidence WHERE dispatch_id = %s", (dispatch_id,)
).fetchone()
leftover_items = conn.execute(
"SELECT id FROM dispatch_items WHERE dispatch_id = %s", (dispatch_id,)
).fetchone()
if leftover_evidence is None and leftover_items is None:
conn.execute("DELETE FROM dispatches WHERE id = %s", (dispatch_id,))
else:
_log(conn, dispatch_id, actor, "Nachweis aus diesem Versand gelöst")
audit(conn, actor, container_row["home_scope_id"], "dispatch_evidence_detached", "element", dispatch["host_element_id"], page)
@@ -1020,6 +1036,7 @@ def _public_evidence(conn, proof, element, page: Ctx) -> dict:
"id": str(proof["id"]),
"element_id": str(element["id"]),
"title": element["title"],
"kind": element["kind"],
"role": proof["role"],
"role_label": EVIDENCE_ROLES[proof["role"]],
"source_state": proof["source_state"],