Template
Closes #9. Shop-gated buyer accounts, purchase reviews, Stripe customer ids, shipment tracking, slim public contact form, and a template-neutral seed_demo command.
33 lines
981 B
Python
33 lines
981 B
Python
from django.contrib import admin
|
|
|
|
from shop.models import Order, OrderItem, Product, ProductReview
|
|
|
|
|
|
@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",)}
|
|
|
|
|
|
@admin.register(ProductReview)
|
|
class ProductReviewAdmin(admin.ModelAdmin):
|
|
list_display = ("product", "user", "rating", "created_at")
|
|
list_filter = ("rating",)
|
|
search_fields = ("product__name", "user__email", "title")
|
|
|
|
|
|
class OrderItemInline(admin.TabularInline):
|
|
model = OrderItem
|
|
extra = 0
|
|
|
|
|
|
@admin.register(Order)
|
|
class OrderAdmin(admin.ModelAdmin):
|
|
list_display = ("number", "email", "amount", "status", "created_at")
|
|
list_filter = ("status",)
|
|
search_fields = ("number", "email", "customer_name")
|
|
raw_id_fields = ("user",)
|
|
inlines = [OrderItemInline]
|