from django.contrib import admin from .models import Brand, Product, Campaign, BrandChatSession @admin.register(Brand) class BrandAdmin(admin.ModelAdmin): list_display = ('name', 'category', 'source', 'collab_count', 'creators_count', 'total_gmv_achieved', 'total_views_achieved', 'shop_overall_rating', 'created_at', 'is_active') search_fields = ('name', 'description', 'category', 'source') list_filter = ('is_active', 'created_at', 'category', 'source') readonly_fields = ('id', 'created_at', 'updated_at') fieldsets = ( ('基本信息', { 'fields': ('id', 'name', 'description', 'logo_url', 'is_active') }), ('分类信息', { 'fields': ('category', 'source', 'collab_count', 'creators_count', 'campaign_id') }), ('统计信息', { 'fields': ('total_gmv_achieved', 'total_views_achieved', 'shop_overall_rating') }), ('知识库关联', { 'fields': ('dataset_id_list',) }), ('时间信息', { 'fields': ('created_at', 'updated_at') }), ) @admin.register(Product) class ProductAdmin(admin.ModelAdmin): list_display = ('name', 'brand', 'pid', 'commission_rate', 'stock', 'items_sold', 'product_rating', 'created_at', 'is_active') search_fields = ('name', 'description', 'brand__name', 'pid') list_filter = ('brand', 'is_active', 'created_at', 'tiktok_shop') readonly_fields = ('id', 'created_at', 'updated_at') fieldsets = ( ('基本信息', { 'fields': ('id', 'name', 'brand', 'description', 'image_url', 'is_active') }), ('产品详情', { 'fields': ('pid', 'commission_rate', 'open_collab', 'available_samples', 'sales_price_min', 'sales_price_max', 'stock', 'items_sold', 'product_rating', 'reviews_count', 'collab_creators', 'tiktok_shop') }), ('知识库信息', { 'fields': ('dataset_id', 'external_id') }), ('时间信息', { 'fields': ('created_at', 'updated_at') }), ) @admin.register(Campaign) class CampaignAdmin(admin.ModelAdmin): list_display = ('name', 'brand', 'service', 'creator_type', 'start_date', 'end_date', 'is_active') search_fields = ('name', 'description', 'brand__name', 'service', 'creator_type') list_filter = ('brand', 'is_active', 'start_date', 'end_date', 'service', 'creator_type') readonly_fields = ('id', 'created_at', 'updated_at') filter_horizontal = ('link_product',) fieldsets = ( ('基本信息', { 'fields': ('id', 'name', 'brand', 'description', 'image_url', 'is_active') }), ('活动详情', { 'fields': ('service', 'creator_type', 'creator_level', 'creator_category', 'creators_count', 'gmv', 'followers', 'views', 'budget') }), ('关联产品', { 'fields': ('link_product',) }), ('活动时间', { 'fields': ('start_date', 'end_date') }), ('知识库信息', { 'fields': ('dataset_id', 'external_id') }), ('时间信息', { 'fields': ('created_at', 'updated_at') }), ) @admin.register(BrandChatSession) class BrandChatSessionAdmin(admin.ModelAdmin): list_display = ('title', 'brand', 'session_id', 'created_at', 'is_active') search_fields = ('title', 'session_id', 'brand__name') list_filter = ('brand', 'is_active', 'created_at') readonly_fields = ('id', 'created_at', 'updated_at') fieldsets = ( ('基本信息', { 'fields': ('id', 'title', 'brand', 'session_id', 'is_active') }), ('知识库信息', { 'fields': ('dataset_id_list',) }), ('时间信息', { 'fields': ('created_at', 'updated_at') }), )