tokens ocnifg 1000 per credit adn fix
This commit is contained in:
@@ -566,6 +566,7 @@ class CreditCostConfigAdmin(SimpleHistoryAdmin, Igny8ModelAdmin):
|
||||
|
||||
list_filter = ['is_active', 'updated_at']
|
||||
search_fields = ['operation_type', 'display_name', 'description']
|
||||
actions = ['bulk_activate', 'bulk_deactivate']
|
||||
|
||||
fieldsets = (
|
||||
('Operation', {
|
||||
@@ -625,6 +626,18 @@ class CreditCostConfigAdmin(SimpleHistoryAdmin, Igny8ModelAdmin):
|
||||
"""Track who made the change"""
|
||||
obj.updated_by = request.user
|
||||
super().save_model(request, obj, form, change)
|
||||
|
||||
@admin.action(description='Activate selected configurations')
|
||||
def bulk_activate(self, request, queryset):
|
||||
"""Bulk activate credit cost configurations"""
|
||||
updated = queryset.update(is_active=True)
|
||||
self.message_user(request, f'{updated} configuration(s) activated.', messages.SUCCESS)
|
||||
|
||||
@admin.action(description='Deactivate selected configurations')
|
||||
def bulk_deactivate(self, request, queryset):
|
||||
"""Bulk deactivate credit cost configurations"""
|
||||
updated = queryset.update(is_active=False)
|
||||
self.message_user(request, f'{updated} configuration(s) deactivated.', messages.WARNING)
|
||||
|
||||
|
||||
class PlanLimitUsageResource(resources.ModelResource):
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
# Generated by Django 5.2.9 on 2025-12-26 01:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0020_create_ai_model_config'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='creditcostconfig',
|
||||
name='operation_type',
|
||||
field=models.CharField(choices=[('clustering', 'Keyword Clustering'), ('idea_generation', 'Content Ideas Generation'), ('content_generation', 'Content Generation'), ('image_generation', 'Image Generation'), ('image_prompt_extraction', 'Image Prompt Extraction'), ('linking', 'Internal Linking'), ('optimization', 'Content Optimization'), ('reparse', 'Content Reparse'), ('site_page_generation', 'Site Page Generation'), ('site_structure_generation', 'Site Structure Generation'), ('ideas', 'Content Ideas Generation'), ('content', 'Content Generation'), ('images', 'Image Generation')], help_text='AI operation type', max_length=50, unique=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='creditusagelog',
|
||||
name='operation_type',
|
||||
field=models.CharField(choices=[('clustering', 'Keyword Clustering'), ('idea_generation', 'Content Ideas Generation'), ('content_generation', 'Content Generation'), ('image_generation', 'Image Generation'), ('image_prompt_extraction', 'Image Prompt Extraction'), ('linking', 'Internal Linking'), ('optimization', 'Content Optimization'), ('reparse', 'Content Reparse'), ('site_page_generation', 'Site Page Generation'), ('site_structure_generation', 'Site Structure Generation'), ('ideas', 'Content Ideas Generation'), ('content', 'Content Generation'), ('images', 'Image Generation')], db_index=True, max_length=50),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='historicalcreditcostconfig',
|
||||
name='operation_type',
|
||||
field=models.CharField(choices=[('clustering', 'Keyword Clustering'), ('idea_generation', 'Content Ideas Generation'), ('content_generation', 'Content Generation'), ('image_generation', 'Image Generation'), ('image_prompt_extraction', 'Image Prompt Extraction'), ('linking', 'Internal Linking'), ('optimization', 'Content Optimization'), ('reparse', 'Content Reparse'), ('site_page_generation', 'Site Page Generation'), ('site_structure_generation', 'Site Structure Generation'), ('ideas', 'Content Ideas Generation'), ('content', 'Content Generation'), ('images', 'Image Generation')], db_index=True, help_text='AI operation type', max_length=50),
|
||||
),
|
||||
]
|
||||
@@ -0,0 +1,18 @@
|
||||
# Generated manually
|
||||
# Fix historical table to allow NULL in calculation_mode column
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('billing', '0021_alter_creditcostconfig_operation_type_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunSQL(
|
||||
sql='ALTER TABLE billing_historicalcreditcostconfig ALTER COLUMN calculation_mode DROP NOT NULL;',
|
||||
reverse_sql='ALTER TABLE billing_historicalcreditcostconfig ALTER COLUMN calculation_mode SET NOT NULL;',
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user