05/15 Update: implement iPad notification function 2

This commit is contained in:
Nguyen Ngo
2026-05-15 15:15:10 -04:00
parent b761f6577e
commit b69a52e5f5
5 changed files with 162 additions and 13 deletions
+18
View File
@@ -873,6 +873,24 @@ def flag_followup(inspection_id):
inspection.follow_up_note = note
db.session.commit()
# Notify the original inspector so they see it on the iPad
inspector = db.session.get(User, inspection.inspector_id)
if inspector and inspector.id != current_user.id:
note_suffix = f' Note: {note}' if note else ''
notify(
recipient = inspector,
title = f'Follow-Up Required: Inspection #{inspection_id}',
body = (
f'{current_user.username} has requested a follow-up re-inspection '
f'of "{inspection.template.name}" at {inspection.facility.name}.{note_suffix}'
),
link = url_for('inspections.view', inspection_id=inspection_id),
inspection_id = inspection_id,
event_type = EVENT_INSPECTION_DONE,
send_email = True,
)
db.session.commit()
current_app.logger.info(
'INSPECTION FOLLOW-UP FLAGGED | id=%s | by=%s | note=%r',
inspection_id, current_user.username, note,