169 lines
2.8 KiB
Python
169 lines
2.8 KiB
Python
from django.contrib import admin
|
|
from unfold.admin import ModelAdmin
|
|
|
|
from shop.models import (
|
|
Brand,
|
|
Cart,
|
|
CartItem,
|
|
CustomerAddress,
|
|
Order,
|
|
OrderLine,
|
|
Product,
|
|
ProductBatch,
|
|
ProductCategory,
|
|
ProductPrice,
|
|
Provider,
|
|
ShippingMethod,
|
|
ShopSettings,
|
|
Tag,
|
|
Tax,
|
|
)
|
|
|
|
|
|
# Register your models here.
|
|
@admin.register(Product)
|
|
class ProductAdmin(ModelAdmin):
|
|
search_fields = ("name",)
|
|
list_display = (
|
|
"id",
|
|
"name",
|
|
"stock",
|
|
)
|
|
|
|
|
|
@admin.register(ProductPrice)
|
|
class ProductPriceAdmin(ModelAdmin):
|
|
search_fields = ("product",)
|
|
autocomplete_fields = ("product",)
|
|
list_display = (
|
|
"id",
|
|
"product",
|
|
"price",
|
|
"date",
|
|
"tax",
|
|
)
|
|
|
|
|
|
@admin.register(Tax)
|
|
class TaxAdmin(ModelAdmin):
|
|
list_display = (
|
|
"code",
|
|
"value",
|
|
)
|
|
|
|
|
|
@admin.register(OrderLine)
|
|
class OrderLineAdmin(ModelAdmin):
|
|
autocomplete_fields = ("product",)
|
|
list_display = (
|
|
"id",
|
|
"product",
|
|
"price",
|
|
"quantity",
|
|
)
|
|
|
|
|
|
@admin.register(Order)
|
|
class OrderAdmin(ModelAdmin):
|
|
list_display = ("id",)
|
|
|
|
|
|
@admin.register(Provider)
|
|
class ProviderAdmin(ModelAdmin):
|
|
list_display = (
|
|
"vat_id",
|
|
"name",
|
|
)
|
|
|
|
|
|
@admin.register(Tag)
|
|
class TagAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"name",
|
|
)
|
|
|
|
|
|
@admin.register(Brand)
|
|
class BrandAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"name",
|
|
)
|
|
|
|
|
|
@admin.register(ProductBatch)
|
|
class ProductBatchAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"product",
|
|
"quantity",
|
|
"provider",
|
|
)
|
|
|
|
|
|
@admin.register(Cart)
|
|
class ProductBatchAdmin(ModelAdmin):
|
|
list_display = (
|
|
"uuid",
|
|
"user",
|
|
"creation_date",
|
|
)
|
|
|
|
|
|
@admin.register(CartItem)
|
|
class ProductBatchAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"cart",
|
|
"product",
|
|
"quantity",
|
|
)
|
|
|
|
|
|
@admin.register(ShippingMethod)
|
|
class ShippingMethodAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"name",
|
|
"description",
|
|
)
|
|
|
|
|
|
@admin.register(CustomerAddress)
|
|
class CustomerAddressAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"user",
|
|
"vat_id",
|
|
"address",
|
|
"address_state",
|
|
"address_zip",
|
|
)
|
|
|
|
def get_queryset(self, request):
|
|
qs = super().get_queryset(request)
|
|
return qs.filter(hidden=False)
|
|
|
|
|
|
@admin.register(ProductCategory)
|
|
class ProductCategoryAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"name",
|
|
"parent",
|
|
"promoted",
|
|
"hidden",
|
|
"show_in_navbar",
|
|
)
|
|
|
|
|
|
@admin.register(ShopSettings)
|
|
class ShopSettingsAdmin(ModelAdmin):
|
|
list_display = (
|
|
"id",
|
|
"merchant_code",
|
|
"currency_code",
|
|
"terminal",
|
|
)
|