blurpritn adn site builde cleanup
This commit is contained in:
@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('igny8_core_auth', '0001_initial'),
|
||||
('site_building', '0001_initial'),
|
||||
# ('site_building', '0001_initial'), # REMOVED: SiteBuilder deprecated
|
||||
('writer', '0001_initial'),
|
||||
]
|
||||
|
||||
@@ -31,12 +31,12 @@ class Migration(migrations.Migration):
|
||||
('account', models.ForeignKey(db_column='tenant_id', on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.account')),
|
||||
('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
|
||||
('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
|
||||
('site_blueprint', models.ForeignKey(help_text='Site blueprint being deployed', on_delete=django.db.models.deletion.CASCADE, related_name='deployments', to='site_building.siteblueprint')),
|
||||
# ('site_blueprint', ...) REMOVED: SiteBuilder deprecated
|
||||
],
|
||||
options={
|
||||
'db_table': 'igny8_deployment_records',
|
||||
'ordering': ['-created_at'],
|
||||
'indexes': [models.Index(fields=['site_blueprint', 'status'], name='igny8_deplo_site_bl_14c185_idx'), models.Index(fields=['site_blueprint', 'version'], name='igny8_deplo_site_bl_34f669_idx'), models.Index(fields=['status'], name='igny8_deplo_status_5cb014_idx'), models.Index(fields=['account', 'status'], name='igny8_deplo_tenant__4de41d_idx')],
|
||||
'indexes': [models.Index(fields=['status'], name='igny8_deplo_status_5cb014_idx'), models.Index(fields=['account', 'status'], name='igny8_deplo_tenant__4de41d_idx')],
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
@@ -56,12 +56,12 @@ class Migration(migrations.Migration):
|
||||
('content', models.ForeignKey(blank=True, help_text='Content being published (if publishing content)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='publishing_records', to='writer.content')),
|
||||
('sector', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.sector')),
|
||||
('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_set', to='igny8_core_auth.site')),
|
||||
('site_blueprint', models.ForeignKey(blank=True, help_text='Site blueprint being published (if publishing site)', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='publishing_records', to='site_building.siteblueprint')),
|
||||
# ('site_blueprint', ...) REMOVED: SiteBuilder deprecated
|
||||
],
|
||||
options={
|
||||
'db_table': 'igny8_publishing_records',
|
||||
'ordering': ['-created_at'],
|
||||
'indexes': [models.Index(fields=['destination', 'status'], name='igny8_publi_destina_5706a3_idx'), models.Index(fields=['content', 'destination'], name='igny8_publi_content_3688ba_idx'), models.Index(fields=['site_blueprint', 'destination'], name='igny8_publi_site_bl_963f5d_idx'), models.Index(fields=['account', 'status'], name='igny8_publi_tenant__2e0749_idx')],
|
||||
'indexes': [models.Index(fields=['destination', 'status'], name='igny8_publi_destina_5706a3_idx'), models.Index(fields=['content', 'destination'], name='igny8_publi_content_3688ba_idx'), models.Index(fields=['account', 'status'], name='igny8_publi_tenant__2e0749_idx')],
|
||||
},
|
||||
),
|
||||
]
|
||||
|
||||
@@ -18,22 +18,14 @@ class PublishingRecord(SiteSectorBaseModel):
|
||||
('failed', 'Failed'),
|
||||
]
|
||||
|
||||
# Content or SiteBlueprint reference (one must be set)
|
||||
# Content reference
|
||||
content = models.ForeignKey(
|
||||
'writer.Content',
|
||||
on_delete=models.CASCADE,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='publishing_records',
|
||||
help_text="Content being published (if publishing content)"
|
||||
)
|
||||
site_blueprint = models.ForeignKey(
|
||||
'site_building.SiteBlueprint',
|
||||
on_delete=models.CASCADE,
|
||||
null=True,
|
||||
blank=True,
|
||||
related_name='publishing_records',
|
||||
help_text="Site blueprint being published (if publishing site)"
|
||||
help_text="Content being published"
|
||||
)
|
||||
|
||||
# Destination information
|
||||
@@ -80,18 +72,17 @@ class PublishingRecord(SiteSectorBaseModel):
|
||||
indexes = [
|
||||
models.Index(fields=['destination', 'status']),
|
||||
models.Index(fields=['content', 'destination']),
|
||||
models.Index(fields=['site_blueprint', 'destination']),
|
||||
models.Index(fields=['account', 'status']),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
target = self.content or self.site_blueprint
|
||||
return f"{target} → {self.destination} ({self.get_status_display()})"
|
||||
return f"{self.content} → {self.destination} ({self.get_status_display()})"
|
||||
|
||||
|
||||
class DeploymentRecord(SiteSectorBaseModel):
|
||||
"""
|
||||
Track site deployments to Sites renderer.
|
||||
Legacy model - SiteBlueprint functionality removed.
|
||||
"""
|
||||
|
||||
STATUS_CHOICES = [
|
||||
@@ -102,12 +93,7 @@ class DeploymentRecord(SiteSectorBaseModel):
|
||||
('rolled_back', 'Rolled Back'),
|
||||
]
|
||||
|
||||
site_blueprint = models.ForeignKey(
|
||||
'site_building.SiteBlueprint',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='deployments',
|
||||
help_text="Site blueprint being deployed"
|
||||
)
|
||||
# Legacy: site_blueprint field removed - now using site from SiteSectorBaseModel directly
|
||||
|
||||
# Version tracking
|
||||
version = models.IntegerField(
|
||||
@@ -148,12 +134,12 @@ class DeploymentRecord(SiteSectorBaseModel):
|
||||
db_table = 'igny8_deployment_records'
|
||||
ordering = ['-created_at']
|
||||
indexes = [
|
||||
models.Index(fields=['site_blueprint', 'status']),
|
||||
models.Index(fields=['site_blueprint', 'version']),
|
||||
models.Index(fields=['status']),
|
||||
models.Index(fields=['account', 'status']),
|
||||
models.Index(fields=['site', 'status']),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.site_blueprint.name} v{self.version} ({self.get_status_display()})"
|
||||
return f"Deployment v{self.version} for {self.site.name if self.site else 'Unknown'} ({self.get_status_display()})"
|
||||
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ class SitesRendererAdapter(BaseAdapter):
|
||||
Returns:
|
||||
dict: Site definition structure
|
||||
"""
|
||||
from igny8_core.business.content.models import Tasks, Content, ContentClusterMap, ContentTaxonomyMap
|
||||
from igny8_core.business.content.models import Tasks, Content, ContentClusterMap
|
||||
|
||||
# Get all pages
|
||||
pages = []
|
||||
@@ -129,8 +129,7 @@ class SitesRendererAdapter(BaseAdapter):
|
||||
'cluster_id': None,
|
||||
'cluster_name': None,
|
||||
'content_structure': None,
|
||||
'taxonomy_id': None,
|
||||
'taxonomy_name': None,
|
||||
'taxonomy_terms': [], # Changed from taxonomy_id/taxonomy_name to list of terms
|
||||
'internal_links': []
|
||||
}
|
||||
|
||||
@@ -180,11 +179,13 @@ class SitesRendererAdapter(BaseAdapter):
|
||||
page_metadata['cluster_name'] = cluster_map.cluster.name
|
||||
page_metadata['content_structure'] = cluster_map.role or task.content_structure if task else None
|
||||
|
||||
# Get taxonomy mapping
|
||||
taxonomy_map = ContentTaxonomyMap.objects.filter(content=content).first()
|
||||
if taxonomy_map and taxonomy_map.taxonomy:
|
||||
page_metadata['taxonomy_id'] = taxonomy_map.taxonomy.id
|
||||
page_metadata['taxonomy_name'] = taxonomy_map.taxonomy.name
|
||||
# Get taxonomy terms using M2M relationship
|
||||
taxonomy_terms = content.taxonomy_terms.all()
|
||||
if taxonomy_terms.exists():
|
||||
page_metadata['taxonomy_terms'] = [
|
||||
{'id': term.id, 'name': term.name, 'type': term.taxonomy_type}
|
||||
for term in taxonomy_terms
|
||||
]
|
||||
|
||||
# Get internal links from content
|
||||
if content.internal_links:
|
||||
|
||||
@@ -1,22 +1,24 @@
|
||||
"""
|
||||
Publisher Service
|
||||
Phase 5: Sites Renderer & Publishing
|
||||
Phase 5: Content Publishing
|
||||
|
||||
Main publishing orchestrator for content and sites.
|
||||
Main publishing orchestrator for content.
|
||||
Legacy: SiteBlueprint publishing removed.
|
||||
"""
|
||||
import logging
|
||||
from typing import Optional, List, Dict, Any
|
||||
|
||||
from igny8_core.business.publishing.models import PublishingRecord, DeploymentRecord
|
||||
from igny8_core.business.site_building.models import SiteBlueprint
|
||||
# Removed: from igny8_core.business.site_building.models import SiteBlueprint
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class PublisherService:
|
||||
"""
|
||||
Main publishing service for content and sites.
|
||||
Main publishing service for content.
|
||||
Routes to appropriate adapters based on destination.
|
||||
Legacy: SiteBlueprint publishing removed.
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
@@ -27,36 +29,6 @@ class PublisherService:
|
||||
"""Lazy load adapters to avoid circular imports"""
|
||||
pass # Will be implemented when adapters are created
|
||||
|
||||
def publish_to_sites(self, site_blueprint: SiteBlueprint) -> Dict[str, Any]:
|
||||
"""
|
||||
Publish site to Sites renderer.
|
||||
|
||||
Args:
|
||||
site_blueprint: SiteBlueprint instance to deploy
|
||||
|
||||
Returns:
|
||||
dict: Deployment result with status and deployment record
|
||||
"""
|
||||
from igny8_core.business.publishing.services.adapters.sites_renderer_adapter import SitesRendererAdapter
|
||||
|
||||
adapter = SitesRendererAdapter()
|
||||
return adapter.deploy(site_blueprint)
|
||||
|
||||
def get_deployment_status(self, site_blueprint: SiteBlueprint) -> Optional[DeploymentRecord]:
|
||||
"""
|
||||
Get deployment status for a site.
|
||||
|
||||
Args:
|
||||
site_blueprint: SiteBlueprint instance
|
||||
|
||||
Returns:
|
||||
DeploymentRecord or None
|
||||
"""
|
||||
from igny8_core.business.publishing.services.deployment_service import DeploymentService
|
||||
|
||||
service = DeploymentService()
|
||||
return service.get_status(site_blueprint)
|
||||
|
||||
def publish_content(
|
||||
self,
|
||||
content_id: int,
|
||||
@@ -216,7 +188,7 @@ class PublisherService:
|
||||
Publish content to multiple destinations.
|
||||
|
||||
Args:
|
||||
content: Content instance or SiteBlueprint
|
||||
content: Content instance
|
||||
destinations: List of destination configs, e.g.:
|
||||
[
|
||||
{'platform': 'wordpress', 'site_url': '...', 'username': '...', 'app_password': '...'},
|
||||
@@ -272,8 +244,7 @@ class PublisherService:
|
||||
account=account,
|
||||
site=content.site,
|
||||
sector=content.sector,
|
||||
content=content if hasattr(content, 'id') and not isinstance(content, SiteBlueprint) else None,
|
||||
site_blueprint=content if isinstance(content, SiteBlueprint) else None,
|
||||
content=content if hasattr(content, 'id') else None,
|
||||
destination=platform,
|
||||
status='published' if result.get('success') else 'failed',
|
||||
destination_id=result.get('external_id'),
|
||||
@@ -319,7 +290,7 @@ class PublisherService:
|
||||
Publish content using site integrations.
|
||||
|
||||
Args:
|
||||
content: Content instance or SiteBlueprint
|
||||
content: Content instance
|
||||
site: Site instance
|
||||
account: Account instance
|
||||
platforms: Optional list of platforms to publish to (all active if None)
|
||||
|
||||
Reference in New Issue
Block a user