Jul 8 - Update scheduled inspection
This commit is contained in:
@@ -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}',
|
||||
|
||||
Reference in New Issue
Block a user