admin pannel update
This commit is contained in:
@@ -287,6 +287,12 @@ UNFOLD = {
|
||||
"icon": "home",
|
||||
"link": reverse_lazy("admin:home_slidermodel_changelist"),
|
||||
},
|
||||
{
|
||||
"title": _("سفارشات"),
|
||||
"icon": "shopping_cart",
|
||||
"link": reverse_lazy("admin:order_ordermodel_changelist"),
|
||||
"badge": "utils.admin.admin_pending_count",
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ from django.contrib.postgres.fields import ArrayField
|
||||
from unfold.widgets import (
|
||||
UnfoldAdminColorInputWidget,
|
||||
)
|
||||
|
||||
from unfold.decorators import action, display
|
||||
class InStuckColorsInLine(TabularInline):
|
||||
model = InStuckColors
|
||||
extra = 1
|
||||
@@ -27,7 +27,7 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
autocomplete_fields = ['related_products']
|
||||
compressed_fields = True
|
||||
warn_unsaved_form = True
|
||||
|
||||
list_display = ['display_image', 'price',]
|
||||
formfield_overrides = {
|
||||
models.TextField: {
|
||||
"widget": WysiwygWidget,
|
||||
@@ -36,6 +36,23 @@ class ProductModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
"widget": ArrayWidget,
|
||||
}
|
||||
}
|
||||
@display(description='محصول', header=True)
|
||||
def display_image(self, instance):
|
||||
if instance.image1:
|
||||
return [
|
||||
instance.name,
|
||||
None,
|
||||
None,
|
||||
{
|
||||
"path": instance.image1.url,
|
||||
"height": 24,
|
||||
"width": 24,
|
||||
"borderless": True,
|
||||
# "squared": True,
|
||||
},
|
||||
]
|
||||
return ()
|
||||
|
||||
|
||||
@admin.register(MainCategoryModel)
|
||||
class MainCategoryModelAdmin(ModelAdmin, ImportExportModelAdmin):
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
from order.models import OrderModel
|
||||
|
||||
def admin_pending_count(request):
|
||||
pending_count = OrderModel.objects.filter(status='ADMIN_PENDING').count()
|
||||
return str(pending_count)
|
||||
Reference in New Issue
Block a user