refactor stage 1

This commit is contained in:
alorig
2025-11-19 19:33:26 +05:00
parent 142077ce85
commit 8b7ed02759
11 changed files with 994 additions and 0 deletions

View File

@@ -5,12 +5,29 @@ from igny8_core.auth.models import SiteSectorBaseModel, SeedKeyword
class Clusters(SiteSectorBaseModel):
"""Clusters model for keyword grouping"""
CONTEXT_TYPE_CHOICES = [
('topic', 'Topic Cluster'),
('attribute', 'Attribute Cluster'),
('service_line', 'Service Line'),
]
name = models.CharField(max_length=255, unique=True, db_index=True)
description = models.TextField(blank=True, null=True)
keywords_count = models.IntegerField(default=0)
volume = models.IntegerField(default=0)
mapped_pages = models.IntegerField(default=0)
status = models.CharField(max_length=50, default='active')
context_type = models.CharField(
max_length=50,
choices=CONTEXT_TYPE_CHOICES,
default='topic',
help_text="Primary dimension for this cluster (topic, attribute, service line)"
)
dimension_meta = models.JSONField(
default=dict,
blank=True,
help_text="Extended metadata (taxonomy hints, attribute suggestions, coverage targets)"
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
@@ -24,6 +41,7 @@ class Clusters(SiteSectorBaseModel):
models.Index(fields=['name']),
models.Index(fields=['status']),
models.Index(fields=['site', 'sector']),
models.Index(fields=['context_type']),
]
def __str__(self):
@@ -61,6 +79,11 @@ class Keywords(SiteSectorBaseModel):
blank=True,
help_text="Site-specific difficulty override (uses seed_keyword.difficulty if not set)"
)
attribute_values = models.JSONField(
default=list,
blank=True,
help_text="Optional attribute metadata (e.g., product specs, service modifiers)"
)
cluster = models.ForeignKey(
'Clusters',
@@ -154,6 +177,20 @@ class ContentIdeas(SiteSectorBaseModel):
('guide', 'Guide'),
('tutorial', 'Tutorial'),
]
SITE_ENTITY_TYPE_CHOICES = [
('page', 'Site Page'),
('blog_post', 'Blog Post'),
('product', 'Product'),
('service', 'Service'),
('taxonomy', 'Taxonomy Page'),
]
CLUSTER_ROLE_CHOICES = [
('hub', 'Hub Page'),
('supporting', 'Supporting Page'),
('attribute', 'Attribute Page'),
]
idea_title = models.CharField(max_length=255, db_index=True)
description = models.TextField(blank=True, null=True)
@@ -174,8 +211,28 @@ class ContentIdeas(SiteSectorBaseModel):
related_name='ideas',
limit_choices_to={'sector': models.F('sector')}
)
taxonomy = models.ForeignKey(
'site_building.SiteBlueprintTaxonomy',
on_delete=models.SET_NULL,
null=True,
blank=True,
related_name='content_ideas',
help_text="Optional taxonomy association when derived from blueprint planning"
)
status = models.CharField(max_length=50, choices=STATUS_CHOICES, default='new')
estimated_word_count = models.IntegerField(default=1000)
site_entity_type = models.CharField(
max_length=50,
choices=SITE_ENTITY_TYPE_CHOICES,
default='page',
help_text="Target entity type when promoting idea into tasks/pages"
)
cluster_role = models.CharField(
max_length=50,
choices=CLUSTER_ROLE_CHOICES,
default='hub',
help_text="Role within the cluster-driven sitemap"
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
@@ -190,6 +247,8 @@ class ContentIdeas(SiteSectorBaseModel):
models.Index(fields=['status']),
models.Index(fields=['keyword_cluster']),
models.Index(fields=['content_structure']),
models.Index(fields=['site_entity_type']),
models.Index(fields=['cluster_role']),
models.Index(fields=['site', 'sector']),
]