"""
Cleanup script to remove notifications with template code in messages
Run: python manage.py shell < cleanup_notifications.py
"""

from custom_admin.models import AdminNotification

print("Cleaning up notifications with template code...")

# Find notifications with template code in message
bad_notifications = AdminNotification.objects.filter(message__contains='{{')
count = bad_notifications.count()

if count > 0:
    print(f"Found {count} notifications with template code")
    bad_notifications.delete()
    print(f"✅ Deleted {count} bad notifications")
else:
    print("✅ No bad notifications found")

print(f"\nRemaining notifications: {AdminNotification.objects.count()}")
