Creditsupdates in fotoer wdigets adn hoemapge and singe site settigns page #Run MIgration 0033 #MAJOR

This commit is contained in:
IGNY8 VPS (Salman)
2026-01-12 07:22:08 +00:00
parent 368601f68c
commit b390e02aa5
17 changed files with 251 additions and 45 deletions

View File

@@ -85,7 +85,16 @@ class CreditUsageLog(AccountBaseModel):
('content', 'Content Generation'), # Legacy
('images', 'Image Generation'), # Legacy
]
# Site relationship - stored at creation time for proper filtering
site = models.ForeignKey(
'igny8_core_auth.Site',
on_delete=models.CASCADE,
null=True,
blank=True,
help_text='Site where the operation was performed'
)
operation_type = models.CharField(max_length=50, choices=OPERATION_TYPE_CHOICES, db_index=True)
credits_used = models.IntegerField(validators=[MinValueValidator(0)])
cost_usd = models.DecimalField(max_digits=10, decimal_places=4, null=True, blank=True)
@@ -105,6 +114,8 @@ class CreditUsageLog(AccountBaseModel):
models.Index(fields=['account', 'operation_type']),
models.Index(fields=['account', 'created_at']),
models.Index(fields=['account', 'operation_type', 'created_at']),
models.Index(fields=['site', 'created_at']),
models.Index(fields=['account', 'site', 'created_at']),
]
def __str__(self):