This commit is contained in:
@@ -397,42 +397,6 @@ class CommissionLogAdmin(ModelAdmin):
|
||||
}),
|
||||
)
|
||||
|
||||
@admin.register(Order)
|
||||
class OrderAdmin(ModelAdmin):
|
||||
list_display = ('id', 'customer_name', 'get_item_name', 'total_price', 'status', 'salesperson', 'distributor', 'created_at')
|
||||
list_filter = ('status', ProductTypeFilter, 'config', 'course', 'activity', PriceRangeFilter, 'salesperson', 'distributor', 'created_at')
|
||||
search_fields = ('id', 'customer_name', 'phone_number', 'wechat_trade_no')
|
||||
readonly_fields = ('total_price', 'created_at', 'wechat_trade_no')
|
||||
actions = [export_to_csv, export_to_excel]
|
||||
|
||||
def get_item_name(self, obj):
|
||||
if obj.config:
|
||||
return f"[硬件] {obj.config.name}"
|
||||
if obj.course:
|
||||
return f"[课程] {obj.course.title}"
|
||||
if obj.activity:
|
||||
return f"[活动] {obj.activity.title}"
|
||||
return "未知商品"
|
||||
get_item_name.short_description = "购买商品"
|
||||
|
||||
fieldsets = (
|
||||
('订单信息', {
|
||||
'fields': ('config', 'course', 'activity', 'quantity', 'total_price', 'status', 'created_at')
|
||||
}),
|
||||
('客户信息', {
|
||||
'fields': ('customer_name', 'phone_number', 'shipping_address', 'wechat_user')
|
||||
}),
|
||||
('物流信息', {
|
||||
'fields': ('courier_name', 'tracking_number')
|
||||
}),
|
||||
('销售归属', {
|
||||
'fields': ('salesperson', 'distributor')
|
||||
}),
|
||||
('支付信息', {
|
||||
'fields': ('wechat_trade_no',)
|
||||
}),
|
||||
)
|
||||
|
||||
class GenderFilter(admin.SimpleListFilter):
|
||||
title = '性别'
|
||||
parameter_name = 'gender'
|
||||
@@ -514,6 +478,42 @@ class ProductTypeFilter(admin.SimpleListFilter):
|
||||
return queryset.filter(activity__isnull=False)
|
||||
return queryset
|
||||
|
||||
@admin.register(Order)
|
||||
class OrderAdmin(ModelAdmin):
|
||||
list_display = ('id', 'customer_name', 'get_item_name', 'total_price', 'status', 'salesperson', 'distributor', 'created_at')
|
||||
list_filter = ('status', ProductTypeFilter, 'config', 'course', 'activity', PriceRangeFilter, 'salesperson', 'distributor', 'created_at')
|
||||
search_fields = ('id', 'customer_name', 'phone_number', 'wechat_trade_no')
|
||||
readonly_fields = ('total_price', 'created_at', 'wechat_trade_no')
|
||||
actions = [export_to_csv, export_to_excel]
|
||||
|
||||
def get_item_name(self, obj):
|
||||
if obj.config:
|
||||
return f"[硬件] {obj.config.name}"
|
||||
if obj.course:
|
||||
return f"[课程] {obj.course.title}"
|
||||
if obj.activity:
|
||||
return f"[活动] {obj.activity.title}"
|
||||
return "未知商品"
|
||||
get_item_name.short_description = "购买商品"
|
||||
|
||||
fieldsets = (
|
||||
('订单信息', {
|
||||
'fields': ('config', 'course', 'activity', 'quantity', 'total_price', 'status', 'created_at')
|
||||
}),
|
||||
('客户信息', {
|
||||
'fields': ('customer_name', 'phone_number', 'shipping_address', 'wechat_user')
|
||||
}),
|
||||
('物流信息', {
|
||||
'fields': ('courier_name', 'tracking_number')
|
||||
}),
|
||||
('销售归属', {
|
||||
'fields': ('salesperson', 'distributor')
|
||||
}),
|
||||
('支付信息', {
|
||||
'fields': ('wechat_trade_no',)
|
||||
}),
|
||||
)
|
||||
|
||||
@admin.register(WeChatUser)
|
||||
class WeChatUserAdmin(OrderableAdminMixin, ModelAdmin):
|
||||
list_display = ('nickname', 'phone_number', 'is_star', 'title', 'avatar_display', 'gender_display', 'province', 'city', 'created_at', 'order_actions')
|
||||
|
||||
Reference in New Issue
Block a user