keywrods status fixes
This commit is contained in:
26
backend/sync_idea_status.py
Normal file
26
backend/sync_idea_status.py
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Sync idea status from completed tasks
|
||||
One-time script to fix existing data
|
||||
"""
|
||||
import os
|
||||
import django
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'igny8_core.settings')
|
||||
django.setup()
|
||||
|
||||
from igny8_core.business.content.models import Tasks
|
||||
from igny8_core.business.planning.models import ContentIdeas
|
||||
|
||||
# Find all completed tasks with ideas
|
||||
completed_tasks = Tasks.objects.filter(status='completed', idea__isnull=False)
|
||||
|
||||
synced = 0
|
||||
for task in completed_tasks:
|
||||
if task.idea and task.idea.status != 'completed':
|
||||
task.idea.status = 'completed'
|
||||
task.idea.save(update_fields=['status', 'updated_at'])
|
||||
synced += 1
|
||||
print(f"Synced idea {task.idea.id} to completed (from task {task.id})")
|
||||
|
||||
print(f"\nTotal synced: {synced} ideas to completed status")
|
||||
Reference in New Issue
Block a user