from django.contrib import admin

from api.models import ExternalIdentifier
from api.models.token import APIUserToken, OAuthToken


class APITokenAdmin(admin.ModelAdmin):
    list_display = [
        "token",
        "valid_until",
        "is_active",
    ]
    readonly_fields = [
        "token"
    ]
    search_fields = [
        "token"
    ]


class OAuthTokenAdmin(admin.ModelAdmin):
    list_display = [
        "access_token",
        "refresh_token",
        "expires_on",
    ]
    search_fields = [
        "access_token",
        "refresh_token",
    ]

class ExternalIdentifierAdmin(admin.ModelAdmin):
    list_display = [
        "external_id",
        "internal_id",
        "created",
    ]
    search_fields = [
        "external_id",
        "internal_id",
    ]

admin.site.register(APIUserToken, APITokenAdmin)
admin.site.register(OAuthToken, OAuthTokenAdmin)
admin.site.register(ExternalIdentifier, ExternalIdentifierAdmin)
