from django.contrib import admin

from accounts.models import Role, Profile, Company


# Register your models here.
@admin.register(Role)
class RoleAdmin(admin.ModelAdmin):
    list_display = ['name', 'slug', 'parent', 'is_active']
    search_fields = ['name', 'slug']
    list_filter = ['is_active']
    ordering = ['parent__name', 'name']

@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
    list_display = [
        "user",
        "fullname",
        "pic_tag",
        "roles_str",
        "affairs",
        "county",
        "broker",
        "is_completed",
        "is_active",
        "jcreated",
    ]
    search_fields = ['user__username', 'user__first_name', 'user__last_name', 'user__phone_number']
    list_filter = ['user', 'roles', 'affairs', 'county', 'broker']
    date_hierarchy = 'created'
    ordering = ['-created']
    readonly_fields = ['created', 'updated']

@admin.register(Company)
class CompanyAdmin(admin.ModelAdmin):
    list_display = ['name', 'logo', 'signature', 'address', 'phone', 'broker', 'registration_number']
    prepopulated_fields = {'slug': ('name',)}
    search_fields = ['name', 'address', 'phone']
    list_filter = ['is_active', 'broker']
    date_hierarchy = 'created'
    ordering = ['-created']