|
|
@@ -1,3 +1,38 @@
|
|
|
from django.contrib import admin
|
|
|
+from .models import Product, ProductType, ProductAttribute, AttributePossibleValue
|
|
|
|
|
|
-# Register your models here.
|
|
|
+
|
|
|
+@admin.register(Product)
|
|
|
+class ProductAdmin(admin.ModelAdmin):
|
|
|
+ list_display = ('item_id', 'product_name', 'product_type', 'image_path')
|
|
|
+ search_fields = ('item_id', 'product_name', 'product_type')
|
|
|
+ list_filter = ('product_type',)
|
|
|
+ readonly_fields = ('image_path',)
|
|
|
+ ordering = ('product_name',)
|
|
|
+
|
|
|
+
|
|
|
+@admin.register(ProductType)
|
|
|
+class ProductTypeAdmin(admin.ModelAdmin):
|
|
|
+ list_display = ('name',)
|
|
|
+ search_fields = ('name',)
|
|
|
+ ordering = ('name',)
|
|
|
+
|
|
|
+
|
|
|
+class AttributePossibleValueInline(admin.TabularInline):
|
|
|
+ model = AttributePossibleValue
|
|
|
+ extra = 1
|
|
|
+
|
|
|
+
|
|
|
+@admin.register(ProductAttribute)
|
|
|
+class ProductAttributeAdmin(admin.ModelAdmin):
|
|
|
+ list_display = ('name', 'product_type', 'is_mandatory')
|
|
|
+ list_filter = ('product_type', 'is_mandatory')
|
|
|
+ search_fields = ('name', 'product_type__name')
|
|
|
+ inlines = [AttributePossibleValueInline]
|
|
|
+
|
|
|
+
|
|
|
+@admin.register(AttributePossibleValue)
|
|
|
+class AttributePossibleValueAdmin(admin.ModelAdmin):
|
|
|
+ list_display = ('attribute', 'value')
|
|
|
+ search_fields = ('attribute__name', 'value')
|
|
|
+ list_filter = ('attribute__product_type',)
|