from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import CustomUser, Character, Feature, Package, PackageFeature, Pin, Asset, ObjectTrait

class CustomUserAdmin(UserAdmin):
    list_display = ('username', 'email', 'first_name', 'last_name', 'is_staff', 'uuid')
    readonly_fields = ('uuid',)
    fieldsets = UserAdmin.fieldsets + (
        (None, {'fields': ('uuid',)}),
    )

admin.site.register(CustomUser, CustomUserAdmin)
admin.site.register(Character)

class PackageFeatureInline(admin.TabularInline):
    model = PackageFeature
    extra = 1
    autocomplete_fields = ['feature']
    fields = ['feature', 'priority']
    ordering = ['priority']

@admin.register(Package)
class PackageAdmin(admin.ModelAdmin):
    inlines = [PackageFeatureInline]
    list_display = ['package_name', 'package_type']
    search_fields = ['package_name', 'package_type']

@admin.register(Feature)
class FeatureAdmin(admin.ModelAdmin):
    list_display = ['feature_name']
    search_fields = ['feature_name']

@admin.register(PackageFeature)
class PackageFeatureAdmin(admin.ModelAdmin):
    list_display = ['package', 'feature', 'priority']
    list_filter = ['package']
    search_fields = ['package__package_name', 'feature__feature_name']

@admin.register(Pin)
class PinAdmin(admin.ModelAdmin):
    list_display = ('label', 'url', 'x', 'y')
    search_fields = ('label', 'url')

@admin.register(Asset)
class AssetAdmin(admin.ModelAdmin):
    list_display = ('asset_name', 'asset_system')
    search_fields = ('asset_name', 'asset_system')

@admin.register(ObjectTrait)
class ObjectTraitAdmin(admin.ModelAdmin):
    list_display = ('trait_name',)
    search_fields = ('trait_name',)