from django.contrib import admin
from .models import Country, Campus, Industry

admin.site.site_header = "HSM Command Center"
admin.site.site_title = "HSM Administration"
admin.site.index_title = "Network intelligence"

@admin.register(Country)
class CountryAdmin(admin.ModelAdmin):
    list_display = ("name", "code", "dialing_code", "campus_count")
    search_fields = ("name", "code")
    ordering = ("name",)

    @admin.display(description="Campuses")
    def campus_count(self, obj): return obj.campuses.count()

@admin.register(Campus)
class CampusAdmin(admin.ModelAdmin):
    list_display = ("name", "institution", "city", "country", "active")
    list_filter = ("active", "country")
    search_fields = ("name", "institution", "city")
    list_editable = ("active",)
    prepopulated_fields = {"slug": ("name",)}
    list_select_related = ("country",)

@admin.register(Industry)
class IndustryAdmin(admin.ModelAdmin):
    list_display = ("name", "active", "display_order")
    list_filter = ("active",)
    search_fields = ("name",)
    list_editable = ("active", "display_order")
    ordering = ("display_order", "name")
