refactor-migration again

This commit is contained in:
IGNY8 VPS (Salman)
2025-11-26 15:12:14 +00:00
parent 2ef98b5113
commit f88aae78b1
23 changed files with 942 additions and 211 deletions

View File

@@ -59,8 +59,8 @@ class KeywordsAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
@admin.register(ContentIdeas)
class ContentIdeasAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
list_display = ['idea_title', 'site', 'sector', 'description_preview', 'site_entity_type', 'cluster_role', 'status', 'keyword_cluster', 'estimated_word_count', 'created_at']
list_filter = ['status', 'site_entity_type', 'cluster_role', 'site', 'sector']
list_display = ['idea_title', 'site', 'sector', 'description_preview', 'content_type', 'content_structure', 'status', 'keyword_cluster', 'estimated_word_count', 'created_at']
list_filter = ['status', 'content_type', 'content_structure', 'site', 'sector']
search_fields = ['idea_title', 'target_keywords', 'description']
ordering = ['-created_at']
readonly_fields = ['created_at', 'updated_at']
@@ -70,7 +70,7 @@ class ContentIdeasAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
'fields': ('idea_title', 'description', 'status', 'site', 'sector')
}),
('Content Planning', {
'fields': ('site_entity_type', 'cluster_role', 'estimated_word_count')
'fields': ('content_type', 'content_structure', 'estimated_word_count')
}),
('Keywords & Clustering', {
'fields': ('keyword_cluster', 'target_keywords', 'taxonomy')

View File

@@ -0,0 +1,49 @@
# Generated by Django 5.2.8 on 2025-11-26 14:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('igny8_core_auth', '0002_add_wp_api_key_to_site'),
('planner', '0004_remove_clusters_igny8_clust_context_0d6bd7_idx_and_more'),
('site_building', '0001_initial'),
]
operations = [
migrations.RemoveIndex(
model_name='contentideas',
name='igny8_conte_site_en_511349_idx',
),
migrations.RemoveIndex(
model_name='contentideas',
name='igny8_conte_cluster_234240_idx',
),
migrations.RemoveField(
model_name='contentideas',
name='cluster_role',
),
migrations.RemoveField(
model_name='contentideas',
name='site_entity_type',
),
migrations.AddField(
model_name='contentideas',
name='content_structure',
field=models.CharField(choices=[('article', 'Article'), ('guide', 'Guide'), ('comparison', 'Comparison'), ('review', 'Review'), ('listicle', 'Listicle'), ('landing_page', 'Landing Page'), ('business_page', 'Business Page'), ('service_page', 'Service Page'), ('general', 'General'), ('cluster_hub', 'Cluster Hub'), ('product_page', 'Product Page'), ('category_archive', 'Category Archive'), ('tag_archive', 'Tag Archive'), ('attribute_archive', 'Attribute Archive')], default='article', help_text='Content structure/format based on content type', max_length=50),
),
migrations.AddField(
model_name='contentideas',
name='content_type',
field=models.CharField(choices=[('post', 'Post'), ('page', 'Page'), ('product', 'Product'), ('taxonomy', 'Taxonomy')], default='post', help_text='Content type: post, page, product, taxonomy', max_length=50),
),
migrations.AddIndex(
model_name='contentideas',
index=models.Index(fields=['content_type'], name='igny8_conte_content_e74415_idx'),
),
migrations.AddIndex(
model_name='contentideas',
index=models.Index(fields=['content_structure'], name='igny8_conte_content_3eede7_idx'),
),
]

View File

@@ -171,8 +171,8 @@ class ContentIdeasSerializer(serializers.ModelSerializer):
'id',
'idea_title',
'description',
'site_entity_type',
'cluster_role',
'content_type',
'content_structure',
'target_keywords',
'keyword_cluster_id',
'keyword_cluster_name',

View File

@@ -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
)