You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
1.1 KiB
37 lines
1.1 KiB
from django.contrib import admin
|
|
from .models import Product, Color, Size, Order, OrderItem, GuestUser
|
|
|
|
@admin.register(Product)
|
|
class ProductAdmin(admin.ModelAdmin):
|
|
list_display = ("title", "ordering_value", "price", "cut")
|
|
|
|
@admin.register(Color)
|
|
class ColorAdmin(admin.ModelAdmin):
|
|
list_display = ("name",)
|
|
|
|
@admin.register(Size)
|
|
class SizeAdmin(admin.ModelAdmin):
|
|
list_display = ("name",)
|
|
|
|
class OrderItemInline(admin.TabularInline):
|
|
model = OrderItem
|
|
extra = 0
|
|
readonly_fields = ('product', 'quantity', 'color', 'size', 'price')
|
|
|
|
@admin.register(Order)
|
|
class OrderAdmin(admin.ModelAdmin):
|
|
list_display = ('id', 'date_ordered', 'status', 'total_price')
|
|
inlines = [OrderItemInline]
|
|
|
|
class GuestUserOrderInline(admin.TabularInline):
|
|
model = Order
|
|
extra = 0
|
|
readonly_fields = ('date_ordered', 'total_price')
|
|
can_delete = False
|
|
show_change_link = True
|
|
exclude = ('user',) # Exclude the user field from the inline display
|
|
|
|
@admin.register(GuestUser)
|
|
class GuestUserAdmin(admin.ModelAdmin):
|
|
list_display = ('email', 'phone')
|
|
inlines = [GuestUserOrderInline]
|
|
|