from django.contrib import admin

from books.models import Book, Topic, Module, ContentBlock
from books.models.chapter import Chapter
from core.wagtail_utils import wagtail_parent_filter


@admin.register(Book)
class BookAdmin(admin.ModelAdmin):
    list_display = ('title', 'slug')


@admin.register(Topic)
class TopicAdmin(admin.ModelAdmin):
    list_display = ('title', 'slug', 'teaser', 'description')
    list_filter = (wagtail_parent_filter(Book, Topic),)


@admin.register(Module)
class ModuleAdmin(admin.ModelAdmin):
    list_display = ('title', 'slug', 'meta_title', 'teaser')
    list_filter = (wagtail_parent_filter(Topic, Module),)


@admin.register(Chapter)
class ChapterAdmin(admin.ModelAdmin):
    list_display = ('title', 'slug')
    list_filter = (wagtail_parent_filter(Module, Chapter),)


@admin.register(ContentBlock)
class ContentBlockAdmin(admin.ModelAdmin):
    list_display = ('title', 'slug')
    list_filter = (wagtail_parent_filter(Chapter, ContentBlock), 'user_created',)
