from django.contrib import admin
from igny8_core.admin.base import AccountAdminMixin
from .models import SiteIntegration, SyncEvent


@admin.register(SiteIntegration)
class SiteIntegrationAdmin(AccountAdminMixin, admin.ModelAdmin):
    list_display = [
        'site',
        'platform',
        'platform_type',
        'is_active',
        'sync_enabled',
        'sync_status',
        'last_sync_at',
    ]
    list_filter = ['platform', 'platform_type', 'is_active', 'sync_enabled', 'sync_status']
    search_fields = ['site__name', 'site__domain', 'platform']
    readonly_fields = ['created_at', 'updated_at']


@admin.register(SyncEvent)
class SyncEventAdmin(AccountAdminMixin, admin.ModelAdmin):
    list_display = [
        'integration',
        'site',
        'event_type',
        'action',
        'success',
        'external_id',
        'created_at',
    ]
    list_filter = ['event_type', 'action', 'success', 'created_at']
    search_fields = ['integration__site__name', 'site__name', 'description', 'external_id']
    readonly_fields = ['created_at']

