from django.contrib import admin
from igny8_core.admin.base import SiteSectorAdminMixin
from .models import PublishingRecord, DeploymentRecord


@admin.register(PublishingRecord)
class PublishingRecordAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
    list_display = [
        'content',
        'site',
        'sector',
        'destination',
        'status',
        'destination_url',
        'published_at',
    ]
    list_filter = ['destination', 'status', 'site']
    search_fields = ['content__title', 'destination', 'destination_url']
    readonly_fields = ['created_at', 'updated_at']


@admin.register(DeploymentRecord)
class DeploymentRecordAdmin(SiteSectorAdminMixin, admin.ModelAdmin):
    list_display = [
        'site',
        'sector',
        'version',
        'deployed_version',
        'status',
        'deployment_url',
        'deployed_at',
    ]
    list_filter = ['status', 'site']
    search_fields = ['site__name', 'deployment_url']
    readonly_fields = ['created_at', 'updated_at']

