Files
OCR/update_templates.py

19 lines
568 B
Python

import sys
import os
sys.path.append(os.path.join(os.getcwd(), 'docengine'))
from app.core.database import SessionLocal
from app.models.template import DocumentFormat
db = SessionLocal()
# Deactivate all templates starting with 'Template_' that have a UUID-like suffix (or just all where description starts with 'Auto-generated')
templates = db.query(DocumentFormat).filter(
DocumentFormat.description.startswith("Auto-generated")
).all()
for t in templates:
t.is_active = False
db.commit()
print(f"Deactivated {len(templates)} auto-generated templates.")