Jul 8 - Update scheduled inspection

This commit is contained in:
2026-07-08 15:46:14 -04:00
parent f08ca997d7
commit 4d661e9776
15 changed files with 795 additions and 6 deletions
+15
View File
@@ -579,6 +579,21 @@ def execute(inspection_id):
inspection_id = inspection.id,
facility_id = inspection.facility_id,
)
# Fulfill the originating scheduled inspection, if any: one-time
# schedules deactivate; recurring ones roll their due date forward
# and reset reminder flags. Staged in the same atomic commit below.
if inspection.scheduled_inspection_id:
from app.models.scheduled_inspection import ScheduledInspection
sched = db.session.get(ScheduledInspection, inspection.scheduled_inspection_id)
if sched is not None:
sched.fulfill()
current_app.logger.info(
'SCHED INSP | fulfilled | schedule=%s | inspection=%s | next_due=%s',
sched.id, inspection.id,
sched.next_due_date if sched.active else 'deactivated',
)
db.session.commit() # Single atomic commit: inspection fields + notification rows
log_action(ACTION_UPDATE, 'Inspection', inspection.id,
f'{inspection.template.name} @ {inspection.facility.name}',