from django.contrib import admin
from .models import User, Dept, Role, Permission, DictType, Dictionary, File, ApiKey
# Register your models here.
admin.site.register(User)
admin.site.register(Dept)
admin.site.register(Role)
admin.site.register(Permission)
admin.site.register(DictType)
admin.site.register(Dictionary)
admin.site.register(File)


@admin.register(ApiKey)
class ApiKeyAdmin(admin.ModelAdmin):
    list_display = ('name', 'key', 'is_active', 'expires_at', 'last_used_at', 'create_time')
    list_filter = ('is_active',)
    search_fields = ('name', 'key')
    readonly_fields = ('key', 'last_used_at')
    fields = ('name', 'key', 'is_active', 'expires_at', 'scopes', 'last_used_at')
