41 lines
1.8 KiB
Python
41 lines
1.8 KiB
Python
![]() |
from django.contrib import admin
|
||
|
from user_management.models import OperatorAccount, PlatformAccount, Video
|
||
|
|
||
|
@admin.register(OperatorAccount)
|
||
|
class OperatorAccountAdmin(admin.ModelAdmin):
|
||
|
list_display = ('username', 'real_name', 'position', 'department', 'is_active', 'created_at')
|
||
|
list_filter = ('position', 'department', 'is_active')
|
||
|
search_fields = ('username', 'real_name', 'email', 'phone')
|
||
|
ordering = ('-created_at',)
|
||
|
|
||
|
@admin.register(PlatformAccount)
|
||
|
class PlatformAccountAdmin(admin.ModelAdmin):
|
||
|
list_display = ('account_name', 'platform_name', 'get_operator_name', 'status', 'followers_count', 'created_at')
|
||
|
list_filter = ('platform_name', 'status')
|
||
|
search_fields = ('account_name', 'account_id', 'operator__real_name')
|
||
|
ordering = ('-created_at',)
|
||
|
|
||
|
def get_operator_name(self, obj):
|
||
|
return obj.operator.real_name
|
||
|
|
||
|
get_operator_name.short_description = '运营账号'
|
||
|
get_operator_name.admin_order_field = 'operator__real_name'
|
||
|
|
||
|
@admin.register(Video)
|
||
|
class VideoAdmin(admin.ModelAdmin):
|
||
|
list_display = ('title', 'get_platform_name', 'get_account_name', 'status', 'views_count', 'created_at')
|
||
|
list_filter = ('status', 'platform_account__platform_name')
|
||
|
search_fields = ('title', 'description', 'platform_account__account_name')
|
||
|
ordering = ('-created_at',)
|
||
|
|
||
|
def get_platform_name(self, obj):
|
||
|
return obj.platform_account.get_platform_name_display()
|
||
|
|
||
|
def get_account_name(self, obj):
|
||
|
return obj.platform_account.account_name
|
||
|
|
||
|
get_platform_name.short_description = '平台'
|
||
|
get_platform_name.admin_order_field = 'platform_account__platform_name'
|
||
|
get_account_name.short_description = '账号名称'
|
||
|
get_account_name.admin_order_field = 'platform_account__account_name'
|