from django.contrib import admin
from django.utils.html import format_html

from accounts.models import Profile


@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
    list_display = ('user', 'is_seller', 'image_preview')

    def image_preview(self, obj):
        if obj.image:
            return format_html(
                '<img src="{}" width="40" height="40" '
                'style="border-radius: 50%; object-fit: cover;" />',
                obj.image.url
            )
        return "No Image"

    image_preview.short_description = 'Image'
