Update views.py
This commit is contained in:
@@ -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,16 +1053,14 @@ 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)
|
||||
|
||||
# Update idea status
|
||||
|
||||
Reference in New Issue
Block a user