"""日结模块管理后台配置"""
from django.contrib import admin
from .models import DailySettlementConfig, NotificationChannelEnum, SettlementModuleEnum


@admin.register(DailySettlementConfig)
class DailySettlementConfigAdmin(admin.ModelAdmin):
    list_display = ['id', 'merchant', 'notification_enabled', 'notification_channel', 'created_at']
    list_filter = ['notification_enabled', 'notification_channel']
    search_fields = ['merchant__name', 'description']
    
    fieldsets = (
        ('基本信息', {
            'fields': ('merchant', 'description')
        }),
        ('统计配置', {
            'fields': ('settlement_modules',)
        }),
        ('通知配置', {
            'fields': ('notification_enabled', 'notification_channel')
        }),
    )
    
    def get_readonly_fields(self, request, obj=None):
        if obj:
            return ['merchant']
        return []
