Update views.py
This commit is contained in:
@@ -1029,6 +1029,22 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
|
|||||||
# Process queueable ideas
|
# Process queueable ideas
|
||||||
for idea in queueable_ideas:
|
for idea in queueable_ideas:
|
||||||
try:
|
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
|
# Direct copy - no mapping needed
|
||||||
task = Tasks.objects.create(
|
task = Tasks.objects.create(
|
||||||
title=idea.idea_title,
|
title=idea.idea_title,
|
||||||
@@ -1037,15 +1053,13 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
|
|||||||
content_type=idea.content_type or 'post',
|
content_type=idea.content_type or 'post',
|
||||||
content_structure=idea.content_structure or 'article',
|
content_structure=idea.content_structure or 'article',
|
||||||
taxonomy_term=None, # Can be set later if taxonomy is available
|
taxonomy_term=None, # Can be set later if taxonomy is available
|
||||||
|
keywords=keywords_str, # Comma-separated keywords string
|
||||||
status='queued',
|
status='queued',
|
||||||
account=idea.account,
|
account=idea.account,
|
||||||
site=idea.site,
|
site=idea.site,
|
||||||
sector=idea.sector,
|
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)
|
created_tasks.append(task.id)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user