"""
Admin configuration for AI models
"""
from django.contrib import admin
from igny8_core.ai.models import AITaskLog


@admin.register(AITaskLog)
class AITaskLogAdmin(admin.ModelAdmin):
    """Admin interface for AI task logs"""
    list_display = [
        'function_name',
        'account',
        'status',
        'phase',
        'cost',
        'tokens',
        'duration',
        'created_at'
    ]
    list_filter = [
        'function_name',
        'status',
        'phase',
        'created_at'
    ]
    search_fields = [
        'function_name',
        'task_id',
        'message',
        'error'
    ]
    readonly_fields = [
        'task_id',
        'function_name',
        'account',
        'phase',
        'message',
        'status',
        'duration',
        'cost',
        'tokens',
        'request_steps',
        'response_steps',
        'error',
        'payload',
        'result',
        'created_at',
        'updated_at'
    ]
    
    def has_add_permission(self, request):
        """Logs are created automatically, no manual creation"""
        return False
    
    def has_change_permission(self, request, obj=None):
        """Logs are read-only"""
        return False

