from django.contrib import admin
from .models import Evenement, Categorie, Candidat

class CandidatInline(admin.TabularInline):
    model = Candidat
    extra = 1

class CategorieInline(admin.TabularInline):
    model = Categorie
    extra = 1

@admin.register(Evenement)
class EvenementAdmin(admin.ModelAdmin):
    list_display = ('titre', 'date_debut', 'date_fin', 'is_active')
    list_editable = ('is_active',)
    inlines = [CategorieInline]

@admin.register(Categorie)
class CategorieAdmin(admin.ModelAdmin):
    list_display = ('nom', 'evenement', 'ordre')
    list_filter = ('evenement',)
    inlines = [CandidatInline]

@admin.register(Candidat)
class CandidatAdmin(admin.ModelAdmin):
    list_display = ('nom_complet', 'categorie', 'ordre')
    list_filter = ('categorie__evenement', 'categorie')