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


class RemembranceAdmin(admin.ModelAdmin):
    list_display = (
        "name",
        "published_on",
        "published",
    )
    # list_filter = ('dod.month', 'dod.year')
    search_fields = (
        "name",
        "body",
    )
    prepopulated_fields = {"slug": ("name",)}
    ordering = ("-published_on",)


class ServiceAdmin(admin.ModelAdmin):
    list_display = (
        "name",
        "announcement",
        "published_on",
        "published",
    )
    # list_filter = ('dod.month', 'dod.year')
    search_fields = (
        "name",
        "body",
    )
    prepopulated_fields = {"slug": ("name",)}
    ordering = ("-published_on",)


class InMemoriamAdmin(admin.ModelAdmin):
    list_display = (
        "title",
        "name",
        "published_on",
        "published",
    )
    # list_filter = ('dod.month', 'dod.year')
    date_hierarchy = "published_on"
    search_fields = (
        "title",
        "body",
    )
    # if not self.title:
    #    prepopulated_fields = {'title': ('first_name', 'middle_name', 'last_name',), 'slug': ('title',)}
    # else:
    prepopulated_fields = {"slug": ("title",)}
    ordering = ("-published_on",)


admin.site.register(Remembrance, RemembranceAdmin)
admin.site.register(InMemoriam, InMemoriamAdmin)
admin.site.register(Service, ServiceAdmin)
admin.site.register(RemembrancePhoto)


class AnnouncementAdmin(admin.ModelAdmin):
    list_display = (
        "full_name",
        "published_on",
        "published",
    )
    list_display = ("full_name",)
    date_hierarchy = "published_on"
    prepopulated_fields = {"slug": ("first_name", "middle_name", "last_name",)}


admin.site.register(Announcement, AnnouncementAdmin)
