diff --git a/backend/igny8_core/modules/planner/views.py b/backend/igny8_core/modules/planner/views.py index 9d2c5eb2..b4eee2e6 100644 --- a/backend/igny8_core/modules/planner/views.py +++ b/backend/igny8_core/modules/planner/views.py @@ -1029,6 +1029,22 @@ class ContentIdeasViewSet(SiteSectorModelViewSet): # Process queueable ideas for idea in queueable_ideas: try: + # Validate required fields + if not idea.keyword_cluster: + errors.append({ + 'idea_id': idea.id, + 'title': idea.idea_title, + 'error': 'Missing required cluster - assign idea to a cluster first' + }) + continue + + # Build keywords string from idea's keyword objects + keywords_str = '' + if idea.keyword_objects.exists(): + keywords_str = ', '.join([kw.keyword for kw in idea.keyword_objects.all()]) + elif idea.target_keywords: + keywords_str = idea.target_keywords + # Direct copy - no mapping needed task = Tasks.objects.create( title=idea.idea_title, @@ -1037,15 +1053,13 @@ class ContentIdeasViewSet(SiteSectorModelViewSet): content_type=idea.content_type or 'post', content_structure=idea.content_structure or 'article', taxonomy_term=None, # Can be set later if taxonomy is available + keywords=keywords_str, # Comma-separated keywords string status='queued', account=idea.account, site=idea.site, sector=idea.sector, + idea=idea, # Link back to the original idea ) - - # Link keywords from idea to task - if idea.keyword_objects.exists(): - task.keywords.set(idea.keyword_objects.all()) created_tasks.append(task.id)