generated from westfarn/web_django_template
CI / test (pull_request) Successful in 35s
Shoppers can register, save shipping details, and view order history while cards stay on Stripe. EasyPost tracker updates (including numbers from Pirate Ship) and 1–5 star reviews are limited to buyers. The contact form now only asks for email and a message.
53 lines
1.3 KiB
Python
53 lines
1.3 KiB
Python
from django.contrib import admin
|
|
|
|
from shop.models import (
|
|
Order,
|
|
OrderItem,
|
|
Product,
|
|
ProductColor,
|
|
ProductImage,
|
|
ProductReview,
|
|
)
|
|
|
|
|
|
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]
|
|
|
|
|
|
@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
|
|
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")
|
|
raw_id_fields = ("user",)
|
|
inlines = [OrderItemInline]
|