from django.contrib import admin
from .models import *


@admin.register(Account)
class AccountAdmin(admin.ModelAdmin):
    # fields = ['name', 'surname', 'phone', 'email', 'register_datetime']
    list_display = ['id', 'name', 'surname', 'role', 'phone', 'register_datetime']
    readonly_fields = ['id', 'register_datetime']


@admin.register(AccountAvatar)
class AccountAvatarAdmin(admin.ModelAdmin):
    # fields = ['name', 'surname', 'phone', 'email', 'register_datetime']
    list_display = ['id', 'account', 'photo', 'profile_background']
    readonly_fields = ['id']


@admin.register(Media)
class MediaAdmin(admin.ModelAdmin):
    list_display = ['id', 'owner', 'original_name', 'size']
    readonly_fields = ['upload_datetime', 'storage_name', 'size']

@admin.register(ExecutorAccount)
class ExecutorAccountAdmin(admin.ModelAdmin):
    # fields = ['name', 'surname', 'phone', 'email', 'register_datetime']
    # list_display = ['name', 'surname', 'phone', 'register_datetime']
    # readonly_fields = ['register_datetime']
    pass


@admin.register(AccessToken)
class AccessTokenAdmin(admin.ModelAdmin):
    readonly_fields = ['id', 'access_token']
    list_display = ['id', 'user', 'creation_time', 'small_access_token']
    fields = ['user', 'creation_time', 'access_token']
    ordering = ['-creation_time']

    def small_access_token(self, obj):
        return f"{obj.access_token[:8]}..."


@admin.register(Order)
class OrderAdmin(admin.ModelAdmin):
    list_display = ['owner', 'phone', 'name', 'create_time', 'moderated', 'published']
    readonly_fields = ['create_time']


@admin.register(Portfolio)
class PortfolioAdmin(admin.ModelAdmin):
    list_display = ['id', 'account', 'title', 'actual_date', 'actual_price']
    readonly_fields = ['actual_date', 'actual_price']


@admin.register(PortfolioPhoto)
class PortfolioAdmin(admin.ModelAdmin):
    # list_display = ['id', 'account', 'title', 'actual_date', 'actual_price']
    # readonly_fields = ['actual_date', 'actual_price']
    pass

#
#
# @admin.register(OrderImage)
# class OrderImageAdmin(admin.ModelAdmin):
#     pass
#
#
# @admin.register(OrderRespond)
# class OrderRespondAdmin(admin.ModelAdmin):
#     pass
