from django.contrib import admin
from .models import MachineModel, SparePart, ServiceIntervention

@admin.register(MachineModel)
class MachineModelAdmin(admin.ModelAdmin):
    list_display = ('name', 'brand')
    search_fields = ('name', 'brand')

@admin.register(SparePart)
class SparePartAdmin(admin.ModelAdmin):
    list_display = ('name', 'reference_code', 'stock_quantity')
    search_fields = ('name', 'reference_code')
    list_filter = ('stock_quantity',)

@admin.register(ServiceIntervention)
class ServiceInterventionAdmin(admin.ModelAdmin):
    list_display = ('machine', 'technician', 'status', 'created_at')
    list_filter = ('status', 'technician', 'created_at')
    search_fields = ('machine__name', 'description')
    autocomplete_fields = ('machine', 'technician')