generated from westfarn/web_django_template
Replaces the client_site template branding, adds shop/shipping, and points beta CI at master for easy deploy. Closes #1
38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
from django.contrib import admin
|
|
|
|
from shop.models import Order, OrderItem, Product, ProductColor, ProductImage
|
|
|
|
|
|
class ProductColorInline(admin.TabularInline):
|
|
model = ProductColor
|
|
extra = 0
|
|
|
|
|
|
class ProductImageInline(admin.TabularInline):
|
|
model = ProductImage
|
|
extra = 0
|
|
|
|
|
|
@admin.register(Product)
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
list_display = ("name", "sku", "price", "stock_qty", "fulfillment", "is_published")
|
|
list_filter = ("fulfillment", "is_published")
|
|
search_fields = ("name", "sku")
|
|
prepopulated_fields = {"slug": ("name",)}
|
|
inlines = [ProductColorInline, ProductImageInline]
|
|
|
|
|
|
class OrderItemInline(admin.TabularInline):
|
|
model = OrderItem
|
|
extra = 0
|
|
fields = ("name", "sku", "color_name", "quantity", "unit_price")
|
|
readonly_fields = ("color_name",)
|
|
|
|
|
|
@admin.register(Order)
|
|
class OrderAdmin(admin.ModelAdmin):
|
|
list_display = ("number", "email", "amount", "status", "created_at")
|
|
list_filter = ("status",)
|
|
search_fields = ("number", "email", "customer_name")
|
|
inlines = [OrderItemInline]
|