refactor-migration again
This commit is contained in:
@@ -927,7 +927,7 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
|
||||
ordering = ['-created_at'] # Default ordering (newest first)
|
||||
|
||||
# Filter configuration (updated for new structure)
|
||||
filterset_fields = ['status', 'keyword_cluster_id', 'site_entity_type', 'cluster_role']
|
||||
filterset_fields = ['status', 'keyword_cluster_id', 'content_type', 'content_structure']
|
||||
|
||||
def perform_create(self, serializer):
|
||||
"""Require explicit site_id and sector_id - no defaults."""
|
||||
@@ -1013,27 +1013,13 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
|
||||
errors = []
|
||||
for idea in ideas:
|
||||
try:
|
||||
# STAGE 3: Map idea fields to final Task schema
|
||||
# Map site_entity_type → content_type (with fallback)
|
||||
content_type = idea.site_entity_type if idea.site_entity_type else 'post'
|
||||
|
||||
# Map cluster_role → content_structure (with fallback)
|
||||
# hub → article, supporting → guide, attribute → comparison
|
||||
role_to_structure = {
|
||||
'hub': 'article',
|
||||
'supporting': 'guide',
|
||||
'attribute': 'comparison',
|
||||
}
|
||||
cluster_role = idea.cluster_role if idea.cluster_role else 'hub'
|
||||
content_structure = role_to_structure.get(cluster_role, 'article')
|
||||
|
||||
# Create task with Stage 1 final fields
|
||||
# Direct copy - no mapping needed
|
||||
task = Tasks.objects.create(
|
||||
title=idea.idea_title,
|
||||
description=idea.description or '',
|
||||
cluster=idea.keyword_cluster,
|
||||
content_type=content_type,
|
||||
content_structure=content_structure,
|
||||
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
|
||||
status='queued',
|
||||
account=idea.account,
|
||||
@@ -1056,7 +1042,7 @@ class ContentIdeasViewSet(SiteSectorModelViewSet):
|
||||
if errors:
|
||||
return error_response(
|
||||
error=f'Failed to create {len(errors)} tasks',
|
||||
details=errors,
|
||||
errors=errors,
|
||||
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
||||
request=request
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user