from django.contrib import admin
from .models import Nomenclature, NomenclatureField, NomenclatureEntry


class NomenclatureFieldInline(admin.TabularInline):
    model = NomenclatureField
    extra = 1


@admin.register(Nomenclature)
class NomenclatureAdmin(admin.ModelAdmin):
    list_display = ['code', 'name', 'applies_to', 'kind', 'sort_order']
    list_filter = ['applies_to', 'kind']
    search_fields = ['code', 'name']
    inlines = [NomenclatureFieldInline]


@admin.register(NomenclatureEntry)
class NomenclatureEntryAdmin(admin.ModelAdmin):
    list_display = ['id', '__str__', 'nomenclature', 'is_active']
    list_filter = ['nomenclature', 'is_active']
