#!/usr/bin/env python3 """ Script to properly fix all signing confirmation modals. Removes inline onsubmit and adds proper JavaScript event handlers. """ import os import re TEMPLATES = { 'ot/templates/ot/session_detail.html': 'ot:session_sign', 'ot/templates/ot/consult_detail.html': 'ot:consult_sign', 'slp/templates/slp/consultation_detail.html': 'slp:consult_sign', 'slp/templates/slp/assessment_detail.html': 'slp:assessment_sign', 'slp/templates/slp/intervention_detail.html': 'slp:intervention_sign', 'slp/templates/slp/progress_detail.html': 'slp:progress_report_sign', 'medical/templates/medical/consultation_detail.html': 'medical:consultation_sign', 'medical/templates/medical/followup_detail.html': 'medical:followup_sign', 'nursing/templates/nursing/encounter_detail.html': 'nursing:encounter_sign', } def fix_template(template_path, sign_url): """Fix a single template.""" if not os.path.exists(template_path): print(f"⚠️ {template_path} not found") return False with open(template_path, 'r') as f: content = f.read() # Check if already has the JS block if 'document.getElementById(\'signForm\')' in content: print(f"ℹ️ {template_path} already fixed") return False # Step 1: Find and replace the form tag - remove onsubmit, add id form_pattern = r'