Jul 17 - Fill the gaps between Single-tenant mode and Multi-tenant mode - MT4

This commit is contained in:
2026-07-17 11:36:05 -04:00
parent 253291d5a4
commit d44d761706
10 changed files with 565 additions and 19 deletions
+14
View File
@@ -580,6 +580,20 @@ def execute(inspection_id):
inspection_id = inspection.id,
facility_id = inspection.facility_id,
)
# Fulfill the originating schedule, if any: roll a recurring plan's
# due date forward and reset its reminder flags. Staged in the same
# atomic commit below. (phase43)
if inspection.inspection_schedule_id:
from app.models.inspection_schedule import InspectionSchedule
from app.routes.inspection_schedules import _compute_next_run
sched = db.session.get(InspectionSchedule, inspection.inspection_schedule_id)
if sched is not None:
sched.fulfill(next_run_fn=_compute_next_run)
current_app.logger.info(
'INSPECTION SCHEDULE | fulfilled | schedule=%s | inspection=%s | next_due=%s',
sched.id, inspection.id, sched.next_run_at,
)
db.session.commit() # Single atomic commit: inspection fields + notification rows
log_action(ACTION_UPDATE, 'Inspection', inspection.id,
f'{inspection.template.name} @ {inspection.facility.name}',