from django.contrib import admin
from .models import ProjectCategory, Project, ProjectImage

class ProjectImageInline(admin.TabularInline):
    model = ProjectImage
    extra = 1

@admin.register(Project)
class ProjectAdmin(admin.ModelAdmin):
    list_display = ('title', 'category', 'date', 'is_featured', 'order')
    list_filter = ('category', 'is_featured', 'date')
    search_fields = ('title', 'summary')
    prepopulated_fields = {'slug': ('title',)}
    filter_horizontal = ('skills',) # Interface sympa pour choisir les compétences
    inlines = [ProjectImageInline] # Gestion de la galerie

@admin.register(ProjectCategory)
class ProjectCategoryAdmin(admin.ModelAdmin):
    list_display = ('name', 'slug', 'order')
    prepopulated_fields = {'slug': ('name',)}