from django.contrib import admin
from podcasts.models import PodcastEpisode, Podcast, Producer
from scrobbles.admin import ScrobbleInline


@admin.register(Producer)
class ProducerAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = ("name",)
    ordering = ("name",)


@admin.register(Podcast)
class PodcastAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "name",
        "producer",
        "active",
    )
    raw_id_fields = ("producer",)
    ordering = ("name",)


@admin.register(PodcastEpisode)
class PodcastEpisodeAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "title",
        "podcast",
    )
    raw_id_fields = ("podcast",)
    list_filter = ("podcast",)
    ordering = ("-created",)
    inlines = [
        ScrobbleInline,
    ]
