from django.contrib import admin
from ..models import oplog


@admin.register(oplog)
class oplog_admin(admin.ModelAdmin):
    list_display = ('create_time', 'content_preview')
    list_filter = ('create_time', )
    search_fields = ('content', )
    date_hierarchy = 'create_time'

    def content_preview(self, obj):
        return obj.content[:100] + '...' if len(
            obj.content) > 100 else obj.content

    content_preview.short_description = '内容摘要'
