delect a little of admin manager parts

This commit is contained in:
2025-10-27 03:35:20 +08:00
parent 15cedbcb95
commit 1fd902fb88

View File

@@ -144,56 +144,56 @@ class CrawledContentAdmin(admin.ModelAdmin):
media_files_display.short_description = '媒体文件'
@admin.register(CrawlLog)
class CrawlLogAdmin(admin.ModelAdmin):
list_display = ['level', 'message_short', 'website', 'task', 'created_at']
list_filter = ['level', 'website', 'task', 'created_at']
search_fields = ['message']
readonly_fields = ['created_at']
ordering = ['-created_at']
def message_short(self, obj):
"""显示缩短的消息"""
return obj.message[:100] + '...' if len(obj.message) > 100 else obj.message
message_short.short_description = '消息'
# @admin.register(CrawlLog)
# class CrawlLogAdmin(admin.ModelAdmin):
# list_display = ['level', 'message_short', 'website', 'task', 'created_at']
# list_filter = ['level', 'website', 'task', 'created_at']
# search_fields = ['message']
# readonly_fields = ['created_at']
# ordering = ['-created_at']
#
# def message_short(self, obj):
# """显示缩短的消息"""
# return obj.message[:100] + '...' if len(obj.message) > 100 else obj.message
# message_short.short_description = '消息'
@admin.register(MediaFile)
class MediaFileAdmin(admin.ModelAdmin):
list_display = ['content', 'media_type', 'file_size_display', 'mime_type', 'created_at']
list_filter = ['media_type', 'created_at']
search_fields = ['content__title', 'original_url', 'alt_text']
readonly_fields = ['created_at', 'file_size_display', 'media_preview']
ordering = ['-created_at']
def media_preview(self, obj):
"""媒体文件预览"""
if obj.media_type == 'image' and obj.local_file:
return format_html(
'<img src="/media/{}" style="max-width: 200px; max-height: 200px;" />',
obj.local_file.name
)
elif obj.media_type == 'video' and obj.local_file:
return format_html(
'<video controls style="max-width: 200px; max-height: 200px;"><source src="/media/{}" type="{}"></video>',
obj.local_file.name,
obj.mime_type
)
elif obj.media_type == 'audio' and obj.local_file:
return format_html(
'<audio controls><source src="/media/{}" type="{}"></audio>',
obj.local_file.name,
obj.mime_type
)
else:
return "无预览"
media_preview.short_description = '预览'
# @admin.register(MediaFile)
# class MediaFileAdmin(admin.ModelAdmin):
# list_display = ['content', 'media_type', 'file_size_display', 'mime_type', 'created_at']
# list_filter = ['media_type', 'created_at']
# search_fields = ['content__title', 'original_url', 'alt_text']
# readonly_fields = ['created_at', 'file_size_display', 'media_preview']
# ordering = ['-created_at']
#
# def media_preview(self, obj):
# """媒体文件预览"""
# if obj.media_type == 'image' and obj.local_file:
# return format_html(
# '<img src="/media/{}" style="max-width: 200px; max-height: 200px;" />',
# obj.local_file.name
# )
# elif obj.media_type == 'video' and obj.local_file:
# return format_html(
# '<video controls style="max-width: 200px; max-height: 200px;"><source src="/media/{}" type="{}"></video>',
# obj.local_file.name,
# obj.mime_type
# )
# elif obj.media_type == 'audio' and obj.local_file:
# return format_html(
# '<audio controls><source src="/media/{}" type="{}"></audio>',
# obj.local_file.name,
# obj.mime_type
# )
# else:
# return "无预览"
# media_preview.short_description = '预览'
@admin.register(SearchKeyword)
class SearchKeywordAdmin(admin.ModelAdmin):
list_display = ['keyword', 'is_active', 'created_at', 'last_used']
list_filter = ['is_active', 'created_at', 'last_used']
search_fields = ['keyword']
list_editable = ['is_active']
ordering = ['-last_used', '-created_at']
# @admin.register(SearchKeyword)
# class SearchKeywordAdmin(admin.ModelAdmin):
# list_display = ['keyword', 'is_active', 'created_at', 'last_used']
# list_filter = ['is_active', 'created_at', 'last_used']
# search_fields = ['keyword']
# list_editable = ['is_active']
# ordering = ['-last_used', '-created_at']