from django.contrib import admin
from .models import Channel, Campaign, MediaAsset, Post


@admin.register(Channel)
class ChannelAdmin(admin.ModelAdmin):
    list_display = ("name", "platform", "handle", "active", "created_at")
    list_filter = ("platform", "active")
    search_fields = ("name", "handle")


@admin.register(Campaign)
class CampaignAdmin(admin.ModelAdmin):
    list_display = ("name", "start_date", "end_date", "created_at")
    search_fields = ("name", "objective")


@admin.register(MediaAsset)
class MediaAssetAdmin(admin.ModelAdmin):
    list_display = ("title", "kind", "size_bytes", "created_at")
    list_filter = ("kind",)


@admin.register(Post)
class PostAdmin(admin.ModelAdmin):
    list_display = ("title", "status", "campaign", "scheduled_at", "published_at")
    list_filter = ("status", "campaign")
    search_fields = ("title", "body")
    autocomplete_fields = ("campaign",)
    filter_horizontal = ("channels", "media")
    readonly_fields = ("published_at", "metrics", "error_message", "created_at", "updated_at")
