display discount model details in overview
This commit is contained in:
parent
e120d6f6e4
commit
cece57a567
1 changed files with 29 additions and 3 deletions
|
@ -322,10 +322,26 @@ class DiscountTierInline(admin.TabularInline):
|
||||||
class ProgressiveDiscountModelAdmin(admin.ModelAdmin):
|
class ProgressiveDiscountModelAdmin(admin.ModelAdmin):
|
||||||
"""Admin configuration for ProgressiveDiscountModel"""
|
"""Admin configuration for ProgressiveDiscountModel"""
|
||||||
|
|
||||||
list_display = ("name", "description", "active")
|
list_display = ("name", "description", "active", "admin_display_discount_tiers")
|
||||||
search_fields = ("name", "description")
|
search_fields = ("name", "description")
|
||||||
inlines = [DiscountTierInline]
|
inlines = [DiscountTierInline]
|
||||||
|
|
||||||
|
def admin_display_discount_tiers(self, obj):
|
||||||
|
"""Display discount tiers in admin list view"""
|
||||||
|
tiers = obj.tiers.all().order_by("min_units")
|
||||||
|
if not tiers:
|
||||||
|
return "No discount tiers"
|
||||||
|
return format_html(
|
||||||
|
"<br>".join(
|
||||||
|
[
|
||||||
|
f"{tier.min_units}-{tier.max_units if tier.max_units else '∞'} units: {tier.discount_percent}%"
|
||||||
|
for tier in tiers
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
admin_display_discount_tiers.short_description = "Discount Tiers"
|
||||||
|
|
||||||
|
|
||||||
@admin.register(VSHNAppCatPrice)
|
@admin.register(VSHNAppCatPrice)
|
||||||
class VSHNAppCatPriceAdmin(admin.ModelAdmin):
|
class VSHNAppCatPriceAdmin(admin.ModelAdmin):
|
||||||
|
@ -350,7 +366,12 @@ class VSHNAppCatPriceAdmin(admin.ModelAdmin):
|
||||||
if not fees:
|
if not fees:
|
||||||
return "No base fees"
|
return "No base fees"
|
||||||
return format_html(
|
return format_html(
|
||||||
"<br>".join([f"{fee.amount} {fee.currency} ({fee.get_service_level_display()})" for fee in fees])
|
"<br>".join(
|
||||||
|
[
|
||||||
|
f"{fee.amount} {fee.currency} ({fee.get_service_level_display()})"
|
||||||
|
for fee in fees
|
||||||
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
admin_display_base_fees.short_description = "Base Fees"
|
admin_display_base_fees.short_description = "Base Fees"
|
||||||
|
@ -618,7 +639,12 @@ class VSHNAppCatAddonAdmin(admin.ModelAdmin):
|
||||||
if not fees:
|
if not fees:
|
||||||
return "No base fees set"
|
return "No base fees set"
|
||||||
return format_html(
|
return format_html(
|
||||||
"<br>".join([f"{fee.amount} {fee.currency} ({fee.get_service_level_display()})" for fee in fees])
|
"<br>".join(
|
||||||
|
[
|
||||||
|
f"{fee.amount} {fee.currency} ({fee.get_service_level_display()})"
|
||||||
|
for fee in fees
|
||||||
|
]
|
||||||
|
)
|
||||||
)
|
)
|
||||||
elif obj.addon_type == "UR": # Unit Rate
|
elif obj.addon_type == "UR": # Unit Rate
|
||||||
rates = obj.unit_rates.all()
|
rates = obj.unit_rates.all()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue