from django.contrib import admin

from boardgames.models import (
    BoardGame,
    BoardGameLocation,
    BoardGamePublisher,
    BoardGameDesigner,
    BoardGameVariant,
)

from scrobbles.admin import ScrobbleInline


@admin.register(BoardGamePublisher)
class BoardGamePublisherAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "name",
        "uuid",
    )
    ordering = ("-created",)


@admin.register(BoardGameDesigner)
class BoardGameDesignerAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "name",
        "uuid",
    )
    ordering = ("-created",)


@admin.register(BoardGameLocation)
class BoardGameLocationAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "name",
        "uuid",
        "geo_location",
    )
    raw_id_fields = ("geo_location",)
    ordering = ("-created",)


@admin.register(BoardGameVariant)
class BoardGameVariantAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "name",
        "board_game",
        "uuid",
    )
    raw_id_fields = ("board_game",)
    search_fields = ("name", "board_game__title")
    ordering = ("-created",)


@admin.register(BoardGame)
class BoardGameAdmin(admin.ModelAdmin):
    date_hierarchy = "created"
    list_display = (
        "bggeek_id",
        "title",
        "published_year",
    )
    raw_id_fields = ("publisher", "publishers", "designers", "expansion_for_boardgame")
    search_fields = ("title",)
    ordering = ("-created",)
    inlines = [
        ScrobbleInline,
    ]
