# -*- coding: utf-8 -*-
from django.contrib import admin
from .models import ChannelZone, ChannelCodec, ChannelZoneRelation, Channel, EPGProgram, Jingle, JingleDetection, ChannelSchedule


@admin.register(ChannelZone)
class ChannelZoneAdmin(admin.ModelAdmin):
    list_display = ('name', 'code', 'timezone', 'is_active')
    list_filter = ('is_active', 'timezone')
    search_fields = ('name', 'code', 'description')
    readonly_fields = ('created_at', 'updated_at')


@admin.register(ChannelZoneRelation)
class ChannelZoneRelationAdmin(admin.ModelAdmin):
    list_display = ("channel", "zone", "codec", "is_active", "priority")
    list_filter = ("is_active", "priority")
    search_fields = ("channel__name", "zone__name")
    readonly_fields = ("created_at", "updated_at")


@admin.register(ChannelCodec)
class ChannelCodecAdmin(admin.ModelAdmin):
    list_display = ('name', 'video_codec', 'audio_codec', 'resolution', 'bitrate')
    search_fields = ('name', 'video_codec', 'audio_codec')
    readonly_fields = ('created_at', 'updated_at')


@admin.register(Channel)
class ChannelAdmin(admin.ModelAdmin):
    list_display = ('name', 'channel_number', 'channel_type', 'status', 'is_online')
    list_filter = ('channel_type', 'status', 'is_online')
    search_fields = ('name', 'display_name', 'channel_number')
    readonly_fields = ('created_at', 'updated_at')


@admin.register(EPGProgram)
class EPGProgramAdmin(admin.ModelAdmin):
    list_display = ('title', 'channel', 'start_time', 'end_time', 'program_type')
    list_filter = ('program_type', 'start_time', 'end_time')
    search_fields = ('title', 'channel__name', 'description')
    readonly_fields = ('created_at', 'updated_at')


@admin.register(Jingle)
class JingleAdmin(admin.ModelAdmin):
    list_display = ('name', 'channel', 'jingle_type', 'duration', 'is_active')
    list_filter = ('jingle_type', 'is_active')
    search_fields = ('name', 'channel__name')
    readonly_fields = ('created_at', 'updated_at')


@admin.register(JingleDetection)
class JingleDetectionAdmin(admin.ModelAdmin):
    list_display = ('jingle', 'channel', 'detected_at', 'confidence_score', 'status')
    list_filter = ('status', 'detected_at')
    search_fields = ('jingle__name', 'channel__name')
    readonly_fields = ('created_at', 'updated_at')


@admin.register(ChannelSchedule)
class ChannelScheduleAdmin(admin.ModelAdmin):
    list_display = ('channel', 'title', 'schedule_type', 'start_time', 'end_time', 'is_active')
    list_filter = ('schedule_type', 'is_active', 'start_time')
    search_fields = ('channel__name', 'title')
    readonly_fields = ('created_at', 'updated_at')
