from django.contrib import admin
from directory.models import *


class PersonAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("first_name", "last_name",)}


class TownAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name", "state")}


admin.site.register(Town, TownAdmin)
admin.site.register(TownInfo)
admin.site.register(PopulationYear)


class PointAdmin(admin.ModelAdmin):
    list_display = (
        "address",
        "town",
        "zipcode",
        "lat_lon",
    )
    list_filter = ("town",)
    search_fields = ("address",)


admin.site.register(Point, PointAdmin)


class PlaceAdmin(admin.ModelAdmin):
    list_display = (
        "title",
        "point",
        "status",
    )
    list_filter = ("status",)
    search_fields = (
        "title",
        "description",
    )
    prepopulated_fields = {"slug": ("title",)}


admin.site.register(Place, PlaceAdmin)


class PersonAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("first_name", "last_name",)}


admin.site.register(Person, PersonAdmin)


class SAUAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("name",)}


admin.site.register(SchoolAdministrativeUnit, SAUAdmin)


class SchoolAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("title",)}
    raw_id_fields = ("point",)
    search_fields = ("title",)


admin.site.register(School, SchoolAdmin)


class PhoneBookEntryAdmin(admin.ModelAdmin):
    list_display = (
        "entry",
        "phone",
        "town",
    )
    search_fields = (
        "entry",
        "phone",
    )
    list_filter = ("town",)


admin.site.register(PhoneBookEntry, PhoneBookEntryAdmin)
admin.site.register(PhoneBookEntryUpload)
