from django.contrib import admin
from products.models import Product, ProductImage


class ProductImageInline(admin.TabularInline):
    model = ProductImage
    extra = 1
    max_num = 3
    readonly_fields = ('id', 'processing_status', 'thumbnail', 'medium', 'large', 'webp')


@admin.register(Product)
class ProductAdmin(admin.ModelAdmin):
    list_display = ('name', 'business', 'base_price', 'is_active', 'created_at')
    list_filter = ('is_active', 'created_at')
    search_fields = ('name', 'business__name')
    readonly_fields = ('id', 'created_at', 'updated_at')
    inlines = [ProductImageInline]
