Pahse 5
This commit is contained in:
159
backend/igny8_core/business/publishing/models.py
Normal file
159
backend/igny8_core/business/publishing/models.py
Normal file
@@ -0,0 +1,159 @@
|
||||
"""
|
||||
Publishing Models
|
||||
Phase 5: Sites Renderer & Publishing
|
||||
"""
|
||||
from django.db import models
|
||||
from igny8_core.auth.models import SiteSectorBaseModel
|
||||
|
||||
|
||||
class PublishingRecord(SiteSectorBaseModel):
|
||||
"""
|
||||
Track content publishing to various destinations.
|
||||
"""
|
||||
|
||||
STATUS_CHOICES = [
|
||||
('pending', 'Pending'),
|
||||
('publishing', 'Publishing'),
|
||||
('published', 'Published'),
|
||||
('failed', 'Failed'),
|
||||
]
|
||||
|
||||
# Content or SiteBlueprint reference (one must be set)
|
||||
content = models.ForeignKey(
|
||||
'content.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)"
|
||||
)
|
||||
|
||||
# Destination information
|
||||
destination = models.CharField(
|
||||
max_length=50,
|
||||
db_index=True,
|
||||
help_text="Destination platform: 'wordpress', 'sites', 'shopify'"
|
||||
)
|
||||
destination_id = models.CharField(
|
||||
max_length=255,
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text="External ID in destination platform"
|
||||
)
|
||||
destination_url = models.URLField(
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text="URL of published content/site"
|
||||
)
|
||||
|
||||
# Status tracking
|
||||
status = models.CharField(
|
||||
max_length=20,
|
||||
choices=STATUS_CHOICES,
|
||||
default='pending',
|
||||
db_index=True
|
||||
)
|
||||
published_at = models.DateTimeField(null=True, blank=True)
|
||||
error_message = models.TextField(blank=True, null=True)
|
||||
|
||||
# Metadata
|
||||
metadata = models.JSONField(
|
||||
default=dict,
|
||||
help_text="Platform-specific metadata"
|
||||
)
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
app_label = 'publishing'
|
||||
db_table = 'igny8_publishing_records'
|
||||
ordering = ['-created_at']
|
||||
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()})"
|
||||
|
||||
|
||||
class DeploymentRecord(SiteSectorBaseModel):
|
||||
"""
|
||||
Track site deployments to Sites renderer.
|
||||
"""
|
||||
|
||||
STATUS_CHOICES = [
|
||||
('pending', 'Pending'),
|
||||
('deploying', 'Deploying'),
|
||||
('deployed', 'Deployed'),
|
||||
('failed', 'Failed'),
|
||||
('rolled_back', 'Rolled Back'),
|
||||
]
|
||||
|
||||
site_blueprint = models.ForeignKey(
|
||||
'site_building.SiteBlueprint',
|
||||
on_delete=models.CASCADE,
|
||||
related_name='deployments',
|
||||
help_text="Site blueprint being deployed"
|
||||
)
|
||||
|
||||
# Version tracking
|
||||
version = models.IntegerField(
|
||||
help_text="Blueprint version being deployed"
|
||||
)
|
||||
deployed_version = models.IntegerField(
|
||||
null=True,
|
||||
blank=True,
|
||||
help_text="Currently deployed version (after successful deployment)"
|
||||
)
|
||||
|
||||
# Status tracking
|
||||
status = models.CharField(
|
||||
max_length=20,
|
||||
choices=STATUS_CHOICES,
|
||||
default='pending',
|
||||
db_index=True
|
||||
)
|
||||
deployed_at = models.DateTimeField(null=True, blank=True)
|
||||
deployment_url = models.URLField(
|
||||
blank=True,
|
||||
null=True,
|
||||
help_text="Public URL of deployed site"
|
||||
)
|
||||
error_message = models.TextField(blank=True, null=True)
|
||||
|
||||
# Metadata
|
||||
metadata = models.JSONField(
|
||||
default=dict,
|
||||
help_text="Deployment metadata (build info, file paths, etc.)"
|
||||
)
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
class Meta:
|
||||
app_label = 'publishing'
|
||||
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']),
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.site_blueprint.name} v{self.version} ({self.get_status_display()})"
|
||||
|
||||
Reference in New Issue
Block a user