product price refactor , admin display name, product models verbose names
This commit is contained in:
@@ -28,7 +28,7 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
autocomplete_fields = ['related_products']
|
||||
# compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
list_display = ['display_image', 'price',]
|
||||
list_display = ['display_image', 'display_price', 'view', 'show', 'rating', 'category', 'discount', 'sell']
|
||||
fieldsets = (
|
||||
('Main Fileds', {'fields': ('name', 'description', 'price', 'min_price', 'currency', 'discount', 'category', 'related_products', 'show',), "classes": ["tab"],}),
|
||||
('SEO Fileds', {'fields': ('meta_description', 'meta_keywords', 'meta_rating', 'slug'), "classes": ["tab"],}),
|
||||
@@ -43,6 +43,11 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
|
||||
def display_price(self, obj):
|
||||
return obj.get_toman_price()
|
||||
display_price.short_description = 'قیمت تومانی'
|
||||
|
||||
@display(description='محصول', header=True)
|
||||
def display_image(self, instance):
|
||||
if instance.image1:
|
||||
@@ -74,7 +79,7 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
class MainCategoryModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
|
||||
list_display = ['name', ]
|
||||
readonly_fields = ('slug', )
|
||||
|
||||
compressed_fields = True
|
||||
@@ -88,6 +93,8 @@ class MainCategoryModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
|
||||
@admin.register(SubCategoryModel)
|
||||
class SubCategoryModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
list_display = ['name', 'parent', 'show']
|
||||
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
|
||||
@@ -106,7 +113,7 @@ class SubCategoryModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
class CommentAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
import_form_class = ImportForm
|
||||
export_form_class = ExportForm
|
||||
|
||||
list_display = ['user', 'product', 'display_content','show']
|
||||
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
@@ -116,6 +123,9 @@ class CommentAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
def display_content(self, obj):
|
||||
return obj.display_content[0:20] + '...'
|
||||
display_content.short_description = 'محتوای کامنت'
|
||||
|
||||
@admin.register(DollorModel)
|
||||
class DollorAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
|
||||
Reference in New Issue
Block a user