no-mistakes(review): Guard photo cleanup; add transitions helper and assign auto-advance

This commit is contained in:
root
2026-08-02 14:26:48 +00:00
parent 237284b012
commit 6b92c9098c
4 changed files with 140 additions and 17 deletions
+18 -1
View File
@@ -236,6 +236,7 @@ async def update_ticket(
# Handle status transitions separately
new_status = data.get("status")
old_status = ticket.status
status_changed = new_status is not None and old_status != new_status
if new_status is not None:
if old_status != new_status:
valid_targets = VALID_TRANSITIONS.get(old_status, [])
@@ -296,9 +297,25 @@ async def update_ticket(
ticket.status = new_status
# Assigning a technician advances pre-Assigned tickets to Assigned with a
# timeline entry; tickets already past Assigned keep their current status.
advanced_to_assigned = False
if "assigned_to" in data and data["assigned_to"] != ticket.assigned_to:
if ticket.status in {"New", "Logged", "Triage"}:
await _log_status_change(
db,
ticket.id,
from_status=ticket.status,
to_status="Assigned",
note=data.get("note") if not status_changed else None,
user_id=user.id if user else None,
)
ticket.status = "Assigned"
advanced_to_assigned = True
# Handle standalone note (no status change)
note_only = data.get("note")
if note_only and not (new_status is not None and old_status != new_status):
if note_only and not status_changed and not advanced_to_assigned:
await _log_status_change(
db,
ticket.id,