All checks were successful
Build and Push Docker Image / build (push) Successful in 50s
- Added `Order` and `OrderItem` models with migrations for managing orders and their details - Created `CheckoutForm` for validating order data and customer information - Built templates for order confirmation, checkout success, and emails (HTML and plain text) - Added logic for email notifications upon successful order placement - Enhanced shopping cart template with checkout panel integration - Updated styles and JavaScript for streamlined checkout UX - Refactored cart view to support item summaries and final totals during checkout
64 lines
1.8 KiB
Python
64 lines
1.8 KiB
Python
from django.contrib import admin
|
|
|
|
from orders.models import Cart, CartItem, Order, OrderItem
|
|
|
|
|
|
class CartItemInline(admin.TabularInline):
|
|
model = CartItem
|
|
extra = 0
|
|
|
|
|
|
@admin.register(Cart)
|
|
class CartAdmin(admin.ModelAdmin):
|
|
list_display = ("user", "updated_at", "created_at")
|
|
search_fields = ("user__username", "user__email")
|
|
inlines = [CartItemInline]
|
|
|
|
|
|
@admin.register(CartItem)
|
|
class CartItemAdmin(admin.ModelAdmin):
|
|
list_display = ("item", "cart", "quantity", "updated_at")
|
|
list_select_related = ("cart", "item", "cart__user")
|
|
search_fields = ("item__name", "cart__user__username", "cart__user__email")
|
|
|
|
|
|
class OrderItemInline(admin.TabularInline):
|
|
model = OrderItem
|
|
extra = 0
|
|
readonly_fields = ("item", "item_name", "item_slug", "item_price", "quantity", "line_total")
|
|
can_delete = False
|
|
|
|
|
|
@admin.register(Order)
|
|
class OrderAdmin(admin.ModelAdmin):
|
|
list_display = ("id", "customer_name", "email", "phone", "status", "total", "created_at")
|
|
list_filter = ("status", "delivery_method", "payment_method", "created_at")
|
|
list_select_related = ("user",)
|
|
search_fields = ("id", "customer_name", "email", "phone", "user__username", "user__email")
|
|
readonly_fields = (
|
|
"user",
|
|
"customer_name",
|
|
"phone",
|
|
"email",
|
|
"delivery_method",
|
|
"region",
|
|
"address",
|
|
"payment_method",
|
|
"promo_code",
|
|
"products_total",
|
|
"discount_total",
|
|
"delivery_total",
|
|
"floor_lift_total",
|
|
"total",
|
|
"status",
|
|
"created_at",
|
|
)
|
|
inlines = [OrderItemInline]
|
|
|
|
|
|
@admin.register(OrderItem)
|
|
class OrderItemAdmin(admin.ModelAdmin):
|
|
list_display = ("item_name", "order", "quantity", "item_price", "line_total")
|
|
list_select_related = ("order", "item")
|
|
search_fields = ("item_name", "order__customer_name", "order__email")
|