"""This module contains the django admin-related class of the ``eventlog`` app"""

from django.contrib import admin

from mtp.apps.common.constants import SYNC_STATUS_FIELDS

from .models import EventLog


ALL_EVENT_FIELDS = (
    'action',
    'subject',
    'target',
    'source',
    'id',
)


class EventLogAdmin(admin.ModelAdmin):
    """Django admin class for the ``EventLog`` model"""

    list_display = ('action', 'source', 'target', 'created_at')
    list_filter = ('action',)
    ordering = ('-created_at',)

    readonly_fields = ALL_EVENT_FIELDS
    fieldsets = (
        (None, {
            'fields': ALL_EVENT_FIELDS,
        }),
        SYNC_STATUS_FIELDS,
    )

admin.site.register(EventLog, EventLogAdmin)
