# -*- coding: utf-8 -*-
from __future__ import annotations

from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.utils.translation import gettext_lazy as _

from hotpocket_backend.apps.accounts.models import Account


class AccountAdmin(UserAdmin):
    list_display = (*UserAdmin.list_display, 'render_is_active')
    ordering = ['username']

    def has_delete_permission(self, request, obj=None):
        return request.user.is_superuser

    @admin.display(
        description=_('Is Active?'), boolean=True, ordering='-is_active',
    )
    def render_is_active(self, obj: Account | None = None) -> bool | None:
        if obj is None:
            return None

        return obj.is_active


admin.site.register(Account, AccountAdmin)
