lot of messs

This commit is contained in:
IGNY8 VPS (Salman)
2025-12-23 14:35:41 +00:00
parent edb64824be
commit 38bc015d96
17 changed files with 2448 additions and 303 deletions

View File

@@ -5,6 +5,61 @@ from django.db import models
from igny8_core.auth.models import AccountBaseModel
class IntegrationState(models.Model):
"""
Tracks whether AI integrations are enabled/disabled for each account.
Single record per account with separate fields for each integration type.
"""
account = models.OneToOneField(
'igny8_core_auth.Account',
on_delete=models.CASCADE,
related_name='integration_state',
help_text='Account that owns this integration state',
primary_key=True
)
# Enable/disable flags for each integration
is_openai_enabled = models.BooleanField(
default=True,
help_text='Whether OpenAI integration is enabled for this account'
)
is_runware_enabled = models.BooleanField(
default=True,
help_text='Whether Runware integration is enabled for this account'
)
is_image_generation_enabled = models.BooleanField(
default=True,
help_text='Whether Image Generation Service is enabled for this account'
)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = 'ai_integration_state'
verbose_name = 'Integration State'
verbose_name_plural = 'Integration States'
indexes = [
models.Index(fields=['is_openai_enabled']),
models.Index(fields=['is_runware_enabled']),
models.Index(fields=['is_image_generation_enabled']),
]
def __str__(self):
states = []
if self.is_openai_enabled:
states.append('OpenAI')
if self.is_runware_enabled:
states.append('Runware')
if self.is_image_generation_enabled:
states.append('Image Gen')
enabled_str = ', '.join(states) if states else 'None'
return f"{self.account.name} - Enabled: {enabled_str}"
class AITaskLog(AccountBaseModel):
"""
Unified logging table for all AI tasks.