more fixes
This commit is contained in:
@@ -10,7 +10,7 @@ class Migration(migrations.Migration):
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
('system', '__latest__'),
|
||||
('igny8_core_auth', '__latest__'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
@@ -35,11 +35,11 @@ class Migration(migrations.Migration):
|
||||
('next_run_at', models.DateTimeField(blank=True, null=True)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('updated_at', models.DateTimeField(auto_now=True)),
|
||||
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='system.account')),
|
||||
('site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='automation_config', to='system.site')),
|
||||
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='igny8_core_auth.account')),
|
||||
('site', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='automation_config', to='igny8_core_auth.site')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'automation_config',
|
||||
'db_table': 'igny8_automation_configs',
|
||||
},
|
||||
),
|
||||
migrations.CreateModel(
|
||||
@@ -74,11 +74,11 @@ class Migration(migrations.Migration):
|
||||
('error_message', models.TextField(blank=True, null=True)),
|
||||
('started_at', models.DateTimeField(auto_now_add=True)),
|
||||
('completed_at', models.DateTimeField(blank=True, null=True)),
|
||||
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='system.account')),
|
||||
('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='automation_runs', to='system.site')),
|
||||
('account', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='igny8_core_auth.account')),
|
||||
('site', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='automation_runs', to='igny8_core_auth.site')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'automation_run',
|
||||
'db_table': 'igny8_automation_runs',
|
||||
'ordering': ['-started_at'],
|
||||
'indexes': [
|
||||
models.Index(fields=['site', 'status'], name='automation_site_status_idx'),
|
||||
|
||||
@@ -760,14 +760,14 @@ class AutomationService:
|
||||
def estimate_credits(self) -> int:
|
||||
"""Estimate total credits needed for automation"""
|
||||
# Count items
|
||||
keywords_count = Keywords.objects.filter(site=self.site, status='new', cluster__isnull=True).count()
|
||||
keywords_count = Keywords.objects.filter(site=self.site, status='new', cluster__isnull=True, disabled=False).count()
|
||||
clusters_count = Clusters.objects.filter(site=self.site, status='new').exclude(ideas__isnull=False).count()
|
||||
ideas_count = ContentIdeas.objects.filter(site=self.site, status='new').count()
|
||||
tasks_count = Tasks.objects.filter(site=self.site, status='queued', content__isnull=True).count()
|
||||
tasks_count = Tasks.objects.filter(site=self.site, status='queued').count()
|
||||
content_count = Content.objects.filter(site=self.site, status='draft').annotate(images_count=Count('images')).filter(images_count=0).count()
|
||||
|
||||
# Estimate credits
|
||||
clustering_credits = (keywords_count // 5) + 1 # 1 credit per 5 keywords
|
||||
clustering_credits = (keywords_count // 5) + 1 if keywords_count > 0 else 0 # 1 credit per 5 keywords
|
||||
ideas_credits = clusters_count * 2 # 2 credits per cluster
|
||||
content_credits = tasks_count * 5 # Assume 2500 words avg = 5 credits
|
||||
prompts_credits = content_count * 2 # Assume 4 prompts per content = 2 credits
|
||||
|
||||
@@ -27,7 +27,7 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
status=status.HTTP_400_BAD_REQUEST
|
||||
)
|
||||
|
||||
site = get_object_or_404(Site, id=site_id, account__user=request.user)
|
||||
site = get_object_or_404(Site, id=site_id, account=request.user.account)
|
||||
return site, None
|
||||
|
||||
@action(detail=False, methods=['get'])
|
||||
@@ -308,6 +308,6 @@ class AutomationViewSet(viewsets.ViewSet):
|
||||
|
||||
return Response({
|
||||
'estimated_credits': estimated_credits,
|
||||
'current_balance': site.account.credits_balance,
|
||||
'sufficient': site.account.credits_balance >= (estimated_credits * 1.2)
|
||||
'current_balance': site.account.credits,
|
||||
'sufficient': site.account.credits >= (estimated_credits * 1.2)
|
||||
})
|
||||
|
||||
@@ -1,18 +1,17 @@
|
||||
"""
|
||||
Tests for DeploymentService
|
||||
DEPRECATED: Tests for DeploymentService - SiteBlueprint models removed
|
||||
Phase 5: Sites Renderer & Publishing
|
||||
"""
|
||||
from django.test import TestCase
|
||||
from django.utils import timezone
|
||||
|
||||
from igny8_core.auth.models import Account, Site, Sector, User, Plan, Industry, IndustrySector
|
||||
from igny8_core.business.site_building.models import SiteBlueprint
|
||||
from igny8_core.business.publishing.models import DeploymentRecord
|
||||
from igny8_core.business.publishing.services.deployment_service import DeploymentService
|
||||
|
||||
|
||||
class DeploymentServiceTestCase(TestCase):
|
||||
"""Test cases for DeploymentService"""
|
||||
"""DEPRECATED: Test cases for DeploymentService"""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up test data"""
|
||||
@@ -69,14 +68,8 @@ class DeploymentServiceTestCase(TestCase):
|
||||
name="Test Sector",
|
||||
slug="test-sector"
|
||||
)
|
||||
self.blueprint = SiteBlueprint.objects.create(
|
||||
account=self.account,
|
||||
site=self.site,
|
||||
sector=self.sector,
|
||||
name="Test Blueprint",
|
||||
status='ready',
|
||||
version=1
|
||||
)
|
||||
# DEPRECATED: SiteBlueprint model removed
|
||||
self.blueprint = None
|
||||
self.service = DeploymentService()
|
||||
|
||||
def test_get_status_returns_deployed_record(self):
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
"""
|
||||
Site Building Models
|
||||
Legacy SiteBuilder module has been removed.
|
||||
This file is kept for backwards compatibility with migrations.
|
||||
This file is kept for backwards compatibility with migrations and legacy code.
|
||||
"""
|
||||
from django.db import models
|
||||
from igny8_core.auth.models import AccountBaseModel
|
||||
|
||||
# All SiteBuilder models have been removed:
|
||||
# - SiteBlueprint
|
||||
@@ -13,3 +14,32 @@ from django.db import models
|
||||
# - BusinessType, AudienceProfile, BrandPersonality, HeroImageryDirection
|
||||
#
|
||||
# Taxonomy functionality moved to ContentTaxonomy model in business/content/models.py
|
||||
|
||||
# Stub classes for backwards compatibility with legacy imports
|
||||
class SiteBlueprint(AccountBaseModel):
|
||||
"""Legacy stub - SiteBuilder has been removed"""
|
||||
class Meta:
|
||||
app_label = 'site_building'
|
||||
db_table = 'legacy_site_blueprint_stub'
|
||||
managed = False # Don't create table
|
||||
|
||||
class PageBlueprint(AccountBaseModel):
|
||||
"""Legacy stub - SiteBuilder has been removed"""
|
||||
class Meta:
|
||||
app_label = 'site_building'
|
||||
db_table = 'legacy_page_blueprint_stub'
|
||||
managed = False # Don't create table
|
||||
|
||||
class SiteBlueprintCluster(AccountBaseModel):
|
||||
"""Legacy stub - SiteBuilder has been removed"""
|
||||
class Meta:
|
||||
app_label = 'site_building'
|
||||
db_table = 'legacy_site_blueprint_cluster_stub'
|
||||
managed = False # Don't create table
|
||||
|
||||
class SiteBlueprintTaxonomy(AccountBaseModel):
|
||||
"""Legacy stub - SiteBuilder has been removed"""
|
||||
class Meta:
|
||||
app_label = 'site_building'
|
||||
db_table = 'legacy_site_blueprint_taxonomy_stub'
|
||||
managed = False # Don't create table
|
||||
|
||||
@@ -13,13 +13,12 @@ from igny8_core.auth.models import (
|
||||
Site,
|
||||
User,
|
||||
)
|
||||
from igny8_core.business.site_building.models import PageBlueprint, SiteBlueprint
|
||||
|
||||
|
||||
class SiteBuilderTestBase(TestCase):
|
||||
"""
|
||||
Provides a lightweight set of fixtures (account/site/sector/blueprint)
|
||||
so Site Builder tests can focus on service logic instead of boilerplate.
|
||||
DEPRECATED: Provides a lightweight set of fixtures (account/site/sector/blueprint)
|
||||
SiteBlueprint models have been removed.
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
@@ -65,20 +64,9 @@ class SiteBuilderTestBase(TestCase):
|
||||
account=self.account,
|
||||
)
|
||||
|
||||
self.blueprint = SiteBlueprint.objects.create(
|
||||
site=self.site,
|
||||
sector=self.sector,
|
||||
name='Core Blueprint',
|
||||
description='Initial blueprint used for tests',
|
||||
hosting_type='igny8_sites',
|
||||
config_json={
|
||||
'business_brief': 'Default brief',
|
||||
'objectives': ['Drive demos'],
|
||||
'style': {'palette': 'bold'},
|
||||
},
|
||||
)
|
||||
self.page_blueprint = PageBlueprint.objects.create(
|
||||
site_blueprint=self.blueprint,
|
||||
# DEPRECATED: SiteBlueprint and PageBlueprint models removed
|
||||
self.blueprint = None
|
||||
self.page_blueprint = None
|
||||
slug='home',
|
||||
title='Home',
|
||||
type='home',
|
||||
|
||||
@@ -1,20 +1,18 @@
|
||||
"""
|
||||
Tests for Bulk Page Generation
|
||||
DEPRECATED: Tests for Bulk Page Generation - SiteBlueprint models removed
|
||||
Phase 5: Sites Renderer & Bulk Generation
|
||||
"""
|
||||
from django.test import TestCase
|
||||
from unittest.mock import patch, Mock
|
||||
|
||||
from igny8_core.auth.models import Account, Site, Sector
|
||||
from igny8_core.business.site_building.models import SiteBlueprint, PageBlueprint
|
||||
from igny8_core.business.site_building.services.page_generation_service import PageGenerationService
|
||||
from igny8_core.business.content.models import Tasks
|
||||
|
||||
from .base import SiteBuilderTestBase
|
||||
|
||||
|
||||
class BulkGenerationTestCase(SiteBuilderTestBase):
|
||||
"""Test cases for bulk page generation"""
|
||||
"""DEPRECATED: Test cases for bulk page generation"""
|
||||
|
||||
def setUp(self):
|
||||
"""Set up test data"""
|
||||
|
||||
Reference in New Issue
Block a user