from django.contrib import admin
from .models import Project, PipelineStep, CgiAsset, Scene, StudioConfig

class PipelineStepInline(admin.TabularInline):
    model = PipelineStep
    extra = 1

class CgiAssetInline(admin.TabularInline):
    model = CgiAsset
    extra = 1

class SceneInline(admin.TabularInline):
    model = Scene
    extra = 1

@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ('title', 'project_type', 'category', 'status', 'is_ai_generated', 'created_at')
    list_filter = ('project_type', 'status', 'is_ai_generated')
    search_fields = ('title', 'description')
    prepopulated_fields = {'slug': ('title',)}
    inlines = [PipelineStepInline, CgiAssetInline, SceneInline]

@admin.register(PipelineStep)
class PipelineStepAdmin(admin.ModelAdmin):
    list_display = ('project', 'name', 'progress', 'is_completed')
    list_filter = ('name', 'is_completed')

@admin.register(CgiAsset)
class CgiAssetAdmin(admin.ModelAdmin):
    list_display = ('name', 'project', 'asset_type', 'is_realistic')
    list_filter = ('asset_type', 'is_realistic')

@admin.register(Scene)
class SceneAdmin(admin.ModelAdmin):
    list_display = ('project', 'number', 'title')
    list_filter = ('project',)

@admin.register(StudioConfig)
class StudioConfigAdmin(admin.ModelAdmin):
    list_display = ('id', 'admin_access_key', 'is_setup')